Jest-puppeteer: How to combine jest-puppeteer and ts-jest?

Created on 13 Jul 2020  ·  2Comments  ·  Source: smooth-code/jest-puppeteer

I configued it like following, but failed?

screenshot_2020-07-14_01-07-31

question ❓

Most helpful comment

Yep, I had some headaches with this as well, I found somewhere that you can actually combine presets into a new preset. You need something like this:

// preset.js
const ts_preset = require('ts-jest/presets/js-with-babel/jest-preset')
const puppeteer_preset = require('jest-puppeteer/jest-preset')

module.exports = Object.assign(
    ts_preset,
    puppeteer_preset
)
````

then reference it from your config (I prefer to keep it in `package.json`

``` json
{
  "jest": {
    "preset": "./preset",
    "testTimeout": 10000
  }
}

All 2 comments

Yep, I had some headaches with this as well, I found somewhere that you can actually combine presets into a new preset. You need something like this:

// preset.js
const ts_preset = require('ts-jest/presets/js-with-babel/jest-preset')
const puppeteer_preset = require('jest-puppeteer/jest-preset')

module.exports = Object.assign(
    ts_preset,
    puppeteer_preset
)
````

then reference it from your config (I prefer to keep it in `package.json`

``` json
{
  "jest": {
    "preset": "./preset",
    "testTimeout": 10000
  }
}

This is my basic setup

jest.config.js

module.exports = {
  preset: 'jest-puppeteer',
  setupFilesAfterEnv: ['expect-puppeteer'],
  testTimeout: 100000,
  globals: {
    'ts-jest': {
      tsConfig: '<rootDir>/tsconfig.json',
    },
  },
};
Was this page helpful?
0 / 5 - 0 ratings

Related issues

FezVrasta picture FezVrasta  ·  4Comments

melissachang picture melissachang  ·  6Comments

macabeus picture macabeus  ·  4Comments

ifiokjr picture ifiokjr  ·  5Comments

igneel64 picture igneel64  ·  5Comments