Jest-puppeteer: Not work well with setupTestFrameworkScriptFile in jest config

Created on 11 Sep 2018  路  2Comments  路  Source: smooth-code/jest-puppeteer

I want to update jest timeout global to wait Webpack dev server compiling codes.
So I add setupTestFrameworkScriptFile in jest config:

jest.config.js:

setupTestFrameworkScriptFile: '<rootDir>/jest.setup.js'

jest.setup.js:

jest.setTimeout(100000);

But after this, await expect(page).toMatch('Page string'); throw expect(string)[.not].toMatch(expected). page is a object.

  it('should display "RingCentral Embeddable" text on page', async () => {
    await page.goto(__HOST_URI__);
    await expect(page).toMatch('Page string'');
  });

If I set timeout in test, it works well:

  it('should display "RingCentral Embeddable" text on page', async () => {
    jest.setTimeout(100000);
    await page.goto(__HOST_URI__);
    await expect(page).toMatch('Page string'');
  });
bug 馃悰

Most helpful comment

The "jest-puppeteer" preset https://github.com/smooth-code/jest-puppeteer/blob/master/packages/jest-puppeteer-preset/jest-preset.json sets the setupTestFrameworkScriptFile already.

So if you override it you just need to import/require in "expect-puppeteer" in your custom setupTestFrameworkScriptFile file.

EX: my puppeteer.setupTests.ts file

import "expect-puppeteer";

// Default is 5 seconds.. our build servers are slow man..
jest.setTimeout(30000);

All 2 comments

The "jest-puppeteer" preset https://github.com/smooth-code/jest-puppeteer/blob/master/packages/jest-puppeteer-preset/jest-preset.json sets the setupTestFrameworkScriptFile already.

So if you override it you just need to import/require in "expect-puppeteer" in your custom setupTestFrameworkScriptFile file.

EX: my puppeteer.setupTests.ts file

import "expect-puppeteer";

// Default is 5 seconds.. our build servers are slow man..
jest.setTimeout(30000);

Thanks @Zoxive, I will not have said better.

Was this page helpful?
0 / 5 - 0 ratings