jest: Test with puppeteer is failed
🐛 Bug Report
I need to run puppeteer tests in separate browser sessions, so I need not the settings for puppetter as described in configure section on the site. So I added puppeteer to the project and wrote the test: App1.test.js
import puppeteer from 'puppeteer';
let page;
let browser;
beforeAll(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto('https://google.com/');
});
afterAll(async () => {
await browser.close();
});
it('should load without error', async () => {
const text = await page.evaluate(() => document.body.textContent);
expect(text).toContain('google');
});
it is failed with error:
● Test suite failed to run
Cannot find module './types/standard' from 'index.js'
at Resolver.resolveModule (../node_modules/jest-resolve/build/index.js:210:17)
at Object.<anonymous> (../node_modules/puppeteer/node_modules/mime/index.js:4:27)
To Reproduce
npm run test
Expected behavior
test is passed
Link to repl or repo (highly encouraged)
here is repo
Run npx envinfo --preset jest
System:
OS: Windows 7
CPU: x64 AMD FX(tm)-6300 Six-Core Processor
Binaries:
Yarn: 1.6.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.1.0 - C:\Program Files\nodejs\npm.CMD
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (8 by maintainers)
You’ve changed the default
moduleFileExtensions
,mime
does not include.json
in itsrequire
: https://github.com/broofa/node-mime/blob/c013a0835a0a7d2c3a91e01fa3c5e08349ddc894/index.js#L4This fixes it: