Otomasi mikrofront, atau bagaimana perpustakaan komponen diuji di Tinkoff

Tampaknya sulit membayangkan aplikasi web yang tidak menggunakan arsitektur microfrontend untuk dapat mengimplementasikan aplikasi yang fleksibel dan fungsional. Dan seperti dalam pendekatan arsitektur apa pun, perlu untuk memberikan pengujian berkualitas tinggi dari komponen yang dikembangkan dalam mikrofrond.


Tapi di mana itu layak dimulai dan apa yang menanti siapa pun yang memasuki jalur otomatisasi mikrofront, ketika banyak yang digunakan untuk menguji aplikasi yang sudah dikumpulkan dari potongan-potongan?



Hei. Nama saya Alexander Vorobei, saya seorang spesialis terkemuka dalam otomatisasi uji di Tinkoff. Pada artikel ini saya akan mencoba untuk memberi tahu Anda secara singkat bagaimana kami memulai otomatisasi dari mikrofront, masalah apa yang kami temui dan hasil apa yang kami dapatkan.


Artikel ini berdasarkan laporan saya dari Konferensi Heisenbug . Ini terdiri dari dua bagian:


  1. Sebuah cerita tentang subjek pengujian dan pilihan alat.
  2. Otomasi: metode, masalah dan solusinya.

Mereka yang ingin mempelajari tentang metode pengujian microfrontend sesegera mungkin dapat dengan aman melanjutkan ke bagian β€œMengotomatiskan pengujian microfrontend”.


Subjek pengujian


β€” . .


β€” , , β€” . ( ) , . β€” .



, , , :


  • . F5 β€” . , .
  • , , .
  • . β€” , β€” , β€” .
  • .

20 ( , ). : , , , . , , Form Builder, . Form Builder



. , β€” . β€” , . , , , . .


, . , , , UI.


. β€” .
:


  1. .
  2. .
  3. .


QA- . , , , - .


, , Storybook.


Storybook:



:


  • Stories β€” . β€” Story.
  • , , .
  • Knobs β€” props, live- , .
  • β€” , , .

:


  • , (, , -, , ) , .
  • , , , .
  • . .


:


  • , β€” Puppeteer, WebdriverIO ( wdio). Wdio Firefox, Safari IE 11.
  • Allure Report.
  • .

CodeceptJS. , , β€” Puppeteer, WebDriverIO, Appium Playwright, β€” .


:


Scenario('   ,   ', async (I) => {
  await I.amOnStory(stories('url'))

  await I.fillField(' ', '01.01.1990')
  await I.fillField('   ', '1111111111')
  await I.fillField('   ', '01.01.2008')
  await I.fillField('   ', '2008')

  await I.clearFieldBySymbols(' ', 1)
  await I.appendFieldManual(' ', '9')

  await I.seeFieldErrorMessage('   ')
  await I.seeFieldErrorMessage('   ')
})

, . Allure-, , , .


?


  • Cypress. , , Cypress , ( ).
  • Wdio. -, , Wdio . -, β€” , . «» .
  • Puppeteer. , . , Wdio, Puppeteer.

CodeceptJS.



, CI/CD Gitlab, -, Gitlab, .


, , , -.



, , .


? , . , , , . , , . , .


, , -. , , -, , .



β€” . β€” !



:


  • . β€” .
  • Form Builder` ( , ).
  • . .
  • .

.



, , , .


, , β€” .


- , : , , -, . , , (), , , .


, LFS. , , , - ( ) , , . , .


Storybook, . Storybook:


  • Master Storybook β€” Storybook , . .
  • Merge Request Storybook β€” Storybook .
    Master Storybook , . git .

, , , , API β€” window.__STORYBOOK_CLIENT_API.getStorybook(). API , . , . nodejs API .


:


const html = fs.readFileSync(`${normalizedPath}/iframe.html`, { encoding: 'utf8' });
const htmlDom = new JSDOM(html);
const scripts = htmlDom.window.document.querySelectorAll('script');
scripts.forEach((script) => {
  if (script.src && script.src.endsWith('bundle.js')) {
    require(path.resolve(normalizedPath, script.src));
  }
});
window.__STORYBOOK_CLIENT_API__.getStorybook().forEach((story) => {...})

β€” js-, require js- node, node API .


, .

, CodeceptJS, :


. :


  • .
  • .
  • ().
  • .
  • .

. .
β€” .


:


42 3 . , !


, 2 14 . , .


API , β€” window.__STORYBOOK_CLIENT_API__._storyStore.setSelection(). , id, β€” .


, β€” , 3 , 554 :


:


  • . β€” .
  • .
  • !

Form Builder`


, 20+ . - Form Builder , Form Builder . Form Builder.


:


  • git- ;
  • yarn.

, git clone. yarn link form-builder From Builder, . Happy-path .


Form Builder, , .



From Builder jobs 30 , 50 . , , .


, , , β€” (Puppeteer Wdio). , karma.


?


Puppeteer Wdio CDP (Chrome DevTools Protocol) WebDriver Protocol . Puppeteer type, API. : "Sends a keydown, keypress/input, and keyup event for each character in the text". Puppeteer DevTools . , - .


( karma) :


  • index.html (, webpack ).
  • , localhost.
  • localhost, , .
  • Web API.

Form Builder karma, 70 3 366 50 .


:

:


:


  • DOM (Web API), , Puppeteer Wdio.
  • (). , .
  • . ? .
  • β€” .
  • . dispatch- .

, .



, , β€” .


- , , . , 1000 , -, , - . .


, lerna, , , , . , .


:


  • .
  • -, .
  • - .
  • , -, - , 100% .
    β€” , unit-.

:


  • β€” .
  • β€” .


:


  • .
  • .
  • - β€” .
  • .
  • , Puppeteer Playwright.
  • core .

All Articles