Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blog/using-jest-with-playwright #37

Open
utterances-bot opened this issue Mar 18, 2021 · 10 comments
Open

blog/using-jest-with-playwright #37

utterances-bot opened this issue Mar 18, 2021 · 10 comments

Comments

@utterances-bot
Copy link

Using Jest with Playwright - Playwright Community 🎭

In this blog post, we'll compare two Jest setups for creating and running end-to-end tests with Playwright.

https://playwright.tech/blog/using-jest-with-playwright

Copy link

let page;
page = await browser.newPage();

The above page object is not compatible with this line below. Apparently they are different Page objects.
await jestPlaywright.saveCoverage(page);

I haven't figured out how to dynamically launch browser and collect coverage info.

import playwright from 'playwright'; 

function initTest(browserType) {
   await playwright[browserType].launch();
}
afterEach(() => {
   await jestPlaywright.saveCoverage(page);
})

Copy link

I am getting error how can I fix this?

TypeError: Jest: a transform must export something.
at C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\transform\build\ScriptTransformer.js:386:19
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Promise.all (index 0)
at async ScriptTransformer.loadTransformers (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\transform\build\ScriptTransformer.js:378:5)
at async createScriptTransformer (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\transform\build\ScriptTransformer.js:1105:3)
at async C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\core\build\runGlobalHook.js:121:27
at async pEachSeries (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules\p-each-series\index.js:8:23)
at async _default (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\core\build\runGlobalHook.js:110:5)
at async runJest (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\core\build\runJest.js:352:5)
at async _run10000 (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\core\build\cli\index.js:408:7)

@arjityadav
Copy link

I am getting error how can I fix this?

TypeError: Jest: a transform must export something.
at C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\transform\build\ScriptTransformer.js:386:19
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Promise.all (index 0)
at async ScriptTransformer.loadTransformers (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\transform\build\ScriptTransformer.js:378:5)
at async createScriptTransformer (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\transform\build\ScriptTransformer.js:1105:3)
at async C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\core\build\runGlobalHook.js:121:27
at async pEachSeries (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules\p-each-series\index.js:8:23)
at async _default (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\core\build\runGlobalHook.js:110:5)
at async runJest (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\core\build\runJest.js:352:5)
at async _run10000 (C:\TeamSpace\PlayWright\PlaywrightTS\node_modules@jest\core\build\cli\index.js:408:7)

did you get any solution?

@ganeshsirsi
Copy link

They are keeping everything updated, latest dependencies doesn't work with playwright you need to install specific version of all dependencies not latest.

Copy link

I am having this error.
FAIL browser: chromium PageObjectTest/TC001_Login.test.ts
● Test suite failed to run

TypeError: Jest: a transform must export something.

  at node_modules/jest-runner/node_modules/@jest/transform/build/ScriptTransformer.js:386:19
      at async Promise.all (index 0)

Can you please tell me how install previous dependencies and remove current one.

@ganeshsirsi
Copy link

https://nodejs.dev/learn/install-an-older-version-of-an-npm-package

Please refer this

Copy link

Which dependencies you downgraded to resolve the problem?

@ganeshsirsi
Copy link

I don't remember exactly but , I think I have downgraded everything 26, you might have follow try and error method here.

Copy link

okay thanks for the help.

Copy link

Hi I have a requirement where I want to test my business logic as well as the components that I have created separately. Can you please suggest how to move forward with it?

  1. Will playwright support independent component testing?
  2. If I am using jest + playwright would I be able to do end to end testing as well as component testing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants