Jest Sequential & Parallel Execution | Playwright - Part 20

Поделиться
HTML-код
  • Опубликовано: 13 дек 2024

Комментарии • 51

  • @purushothamnikhil
    @purushothamnikhil 2 года назад +1

    Hi When i am running the tests it is giving error as
    No tests found, exiting with code 1
    Run with `--passWithNoTests` to exit with code 0
    In D:\Violet\playwrite\poc
    9 files checked.
    testMatch: rootDir/test/bulkedit/**.ts - 0 matches

    • @letcode
      @letcode  2 года назад

      Hi bro.
      Test match pattern might be wrong.
      Check the file path.

  • @i.am.sameer
    @i.am.sameer 2 года назад +1

    How can we execute the same test on chromium and firefox concurrently with jest...? Just by mentioning the browsers in the config is executing it sequentially.-> browsers: ["chromium","firefox"]

    • @letcode
      @letcode  2 года назад +1

      You can use the worker option for that.

  • @feralgoose7157
    @feralgoose7157 3 года назад +1

    Great stuff, I extended my jest to use projects so I can configure unit/functional and e2e, but still use the initial jest config as well. Very useful information.

    • @balramshrivastav728
      @balramshrivastav728 3 года назад

      hey Feral Goose can you tell me what changes did you make to run the test cases in parallel because according to the tutorial I have followed the same steps but it's not executing all test suites unexpectedly closing the browser

  • @karthic5231
    @karthic5231 3 года назад +1

    i had a 5 test case scenario in the test/pageobjects then i wish to run only two how counld i do it...you told jest -i is sequencial right..but i need to specfic the file name like test/PageObjects/scenario_001.ts and test/PageObjects/scenario_004.ts only i want to run means like pom.xml we can do it in the test ng like that here we can specify the two path with comman sperator is it right.

    • @letcode
      @letcode  3 года назад

      Yeah with in the testmatch we can mention n number of files with comma separated..

  • @animeshmishra124
    @animeshmishra124 2 года назад +1

    how to make sure that 2 specific files(x.test.ts & y.test.ts) never run together parallelly in playwright?

    • @letcode
      @letcode  2 года назад

      Good question, but i don't have answer now 😞.
      I'll check.

    • @letcode
      @letcode  2 года назад

      projects: [
      {
      testMatch: [/.*smoke.spec.ts/]
      },
      You can use like this, with in test match you can specific those 2 tests

  • @MrH0bb0
    @MrH0bb0 Год назад +1

    I have not integrated my Playwright to Jest. I am using just factory default Playwright.
    In my test folder I have two test files namely:
    1. file1.test.ts
    2. file2.test.ts
    When I am running in Parallel mode by settings workers = 2 in playwright.config.ts, its running the test case of the single file in different browser instances due to which my test case is failing as the first test case was to login and second is to perform the required action.
    Can you please suggest how can I overcome this issue?

    • @letcode
      @letcode  Год назад

      You have to use the serial mode.
      Pls refer to this video
      ruclips.net/video/q8oZD5uO6_s/видео.html

    • @MrH0bb0
      @MrH0bb0 Год назад

      @@letcode Thanks a lot, this worked.
      I have two new queries, could you please help?
      1. Playwright browser is getting closed without the expect statement execution is finished. Expect only works if I have another locator present after the expect statement.
      2. Even though videos are turned on, videos are not being recorded.
      Looking forward to hearing from you soon.
      I hope you continue helping the less minded like me as always :)

    • @MrH0bb0
      @MrH0bb0 Год назад +1

      ​@@letcode
      Update on the issues:
      1. expect wasn't working because I missed to add ''await" keyword before the expect statement, however, out of 116 expect statements, there's one which is not working and returning the following error:
      Error: expect: Property 'then' not found.
      243 |
      244 | await app.editProperties.save().click();
      > 245 | await expect(util.controls.alert.success.message(), data.message.success.editProperties);
      | ^
      246 | await util.controls.alert.success.closeBtn().click()
      247 | });
      248 |
      at C:\Playwright_Automation\Playwright_Automation\tests\app\poc-smoke-test-suite.test.ts:245:21
      Here,
      message: () => this.page.locator('.alert-success message-content'),
      writing await expect(await util.controls.alert.success.message(), data.message.success.editProperties);
      is also throwing the same error.
      Have you ever come across such issue?
      I am using the same expect statement in the same test file for different messages like 20+ times, but its failing only for this one.
      =====================================NOTE: Temporary Fix========================================
      The error does not persists if I rewrite the same expect statement as following:
      expect(await util.controls.alert.success.message(), data.message.success.editProperties);
      ==============================================================================================
      2. Video not being recorded: I searched online and I found that there's a closed issue [github.com/playwright-community/jest-playwright/issues/708]. There's a solution to create a super teardown method , but I don't know where to place it. :/

    • @letcode
      @letcode  Год назад

      I have covered all those on the playwright playlist, pls go through that.

  • @BobbyKumar-mb4hd
    @BobbyKumar-mb4hd Год назад +2

    do you have any video for electron app with playwright testt

    • @letcode
      @letcode  Год назад

      Not yet 😕

    • @BobbyKumar-mb4hd
      @BobbyKumar-mb4hd Год назад +2

      @@letcode can you create a video for that

    • @letcode
      @letcode  Год назад

      @@BobbyKumar-mb4hd if I get any good sample application then definitely i can.

    • @BobbyKumar-mb4hd
      @BobbyKumar-mb4hd Год назад +1

      I am writing test cases electron app but I am a stuck little bit and the document is not clear for the electron and is very thankful to you if can make a video for the electron app.

    • @BobbyKumar-mb4hd
      @BobbyKumar-mb4hd Год назад

      @@letcode can we use the code gen in playwright application

  • @balramshrivastav728
    @balramshrivastav728 3 года назад +1

    I have four test suites to execute in parallel like account.test.js, post.test.js, action.test.js, and invite.test.js but the problem is while I am executing the last test suite the browser is getting close without executing the last test suite. please tell me what could be the reason?

    • @letcode
      @letcode  3 года назад

      Did u check report, anything suspicious?

    • @balramshrivastav728
      @balramshrivastav728 3 года назад

      @@letcode yes, I got the details of 3 test suites out of 4 because the 4th test suite is closed unexpectedly when the test cases are running.
      Below is the code that I had done already to achieve the parallel execution
      This is the jest.config.js file
      preset: "jest-puppeteer",
      testMatch: [
      "/tests/paralleltest/**.test.js",
      ],
      This is the jest-puppeteer.config.js file
      module.exports = {
      launch: {
      headless: false,
      exitOnPageError: true,
      args: ['--no-sandbox','--disable-notifications','--start-maximized','--force-device-scale-factor=1.0'],
      defaultViewport: null,

      },

      browserContext: "incognito",
      };
      This is the folder structure for parallel execution
      test/paralleltest/account.test.js,invite.test.js,action.test.js
      This is the script for parallel execution
      "parallel_testing":" jest ",

  • @krishnae5142
    @krishnae5142 2 года назад +1

    Hi Koushik, I am trying to execute single testcase with title and tried using 'jest -t '@Reg' but it gave Reference error .Similar functionality exists in Playwright - npx playwright test --grep @Reg . Can you suggest if there is a way to do this in Playwright Jest.
    Thank you.

    • @letcode
      @letcode  2 года назад

      jest -t name-of-spec this is command, not sure y u r getting error.
      I'll recommend to switch to playwright test runner, it's awesome.
      More control over jest.

    • @krishnae5142
      @krishnae5142 2 года назад +1

      Am trying Playwright test runner as well. But how can I pass 'TestInfo' to a page so that i can attach screenshot or use that in report . Any example can you please give me.

    • @letcode
      @letcode  2 года назад +1

      That's a new feature, i will create a video.

    • @krishnae5142
      @krishnae5142 2 года назад +1

      Thank you .If you could do it little faster Would be really helpful

  • @sankarsankar-bj4rk
    @sankarsankar-bj4rk 3 года назад +1

    Can we able to able to control the parallel execution threads. like i need to run only 3 test case parallel ?

    • @letcode
      @letcode  3 года назад

      Yes we can, we have to use the -worker=3

    • @sankarsankar-bj4rk
      @sankarsankar-bj4rk 3 года назад

      @@letcode - this keyword works in Jest or only in playwright runner ?

    • @letcode
      @letcode  3 года назад

      Workers is for playwright test runner.

  • @alexandrapandelea353
    @alexandrapandelea353 3 года назад +1

    I am using jest with puppeteer and I want to run 2 tests in parallel, meaning that I want 2 headless chrome instances to be opened and running at the same. The problem is that only one browser does the test and the other one doesn't. I am trying to configure the browser setUp, but still haven't figure it out. Do you have any ideas? Thank you!!

    • @letcode
      @letcode  3 года назад

      I have used playwright in this video, but set up is almost same. Did u tried as per the video ?

    • @alexandrapandelea353
      @alexandrapandelea353 3 года назад +1

      @@letcode I managed to do it, it wasn't simple, but I did it haha. Thank you so much!!

    • @letcode
      @letcode  3 года назад

      Great 😊

  • @balajiekambaram
    @balajiekambaram 3 года назад +2

    Good one brother.. can you pls make a video to understand the utility class that has all common functions like click, all types of waits, set or fill etc.,, And also how to maintain test blocks inSide describe in bigger projects, and read data from Excel for execution.

    • @letcode
      @letcode  3 года назад

      Sure bro.
      So far we have used only the POM, in upcoming videos we'll implement common functions.

  • @saranyab2304
    @saranyab2304 3 года назад +1

    Hi Sir, I have a doubt in sequential run.If suppose we have create.js, delete.js,update.js,in this case delete will execute before updatw.so do we have to name to js file in ascending order? Or do we have priority in testng ??thanks for ur video Sir

    • @letcode
      @letcode  3 года назад +1

      Good question, testmatch accept string array. So you can specify based on the file name sequence. It will run in the sequence as we declared.

    • @mohitchauhan569
      @mohitchauhan569 2 года назад

      @@letcode not working sequentially here 002.e2e-spec.ts file execute 1st could you pls help? "testMatch": ["/A320_FOR_IT/001.e2e-spec.ts","/A320_FOR_IT/002.e2e-spec.ts"],

  • @balramshrivastav728
    @balramshrivastav728 3 года назад

    sir, can I do like I have 4 different users and I have one test script for e.g login.test.js
    and I want to run parallel for all 4 users. can I do this?

    • @letcode
      @letcode  3 года назад

      Yes, we can do. To achieve that we have to use the worker concept.

  • @aakashpatkar2648
    @aakashpatkar2648 3 года назад +1

    Is it possible to run test cases in alphabetical order?

    • @letcode
      @letcode  3 года назад

      testmatch accept string array. So you can specify based on the file name sequence. It will run in the sequence as we declared.

  • @sanujatharinda6525
    @sanujatharinda6525 2 года назад +1

    Great tutorial

  • @nagulrd5214
    @nagulrd5214 3 года назад +1

    ❤️

    • @nagulrd5214
      @nagulrd5214 3 года назад

      Waiting for pom video bro