dockest icon indicating copy to clipboard operation
dockest copied to clipboard

Passing in 'config' option to `jestOpts` does not do anything

Open HenryNguyen5 opened this issue 5 years ago • 4 comments

Describe the bug If we have two files, jest.config.js and jest.config.integration.js, the latter will always be ignored of the former despite setting jestOpts to jest.config.integration.js

HenryNguyen5 avatar Mar 19 '20 21:03 HenryNguyen5

Describe the bug If we have two files, jest.config.js and jest.config.integration.js, the latter will always be ignored of the former despite setting jestOpts to `jest.integration.js.

Hey!

You wrote your config file in two different ways - could that be the problem?

jest.integration.js doesn't match either jest.config.js or jest.config.integration.js

erikengervall avatar May 01 '20 07:05 erikengervall

Ah its been awhile since this occurred, I believe I did not have a typo when I was actually testing it though.

HenryNguyen5 avatar May 04 '20 20:05 HenryNguyen5

Ah its been awhile since this occurred, I believe I did not have a typo when I was actually testing it though.

This particular issue does sound familiar, and I'm not entirely sure what the root cause might be 😕I have tested this explicitly in the past and see at least some options work without issues - might there be something with Jest's runCLI method that strips some of the options perhaps?

Do you have a theory of what it might be?

erikengervall avatar May 04 '20 20:05 erikengervall

As a workaround, you can import your jest.config.integration.js and use it in your dockest.ts. For example like this:

// dockest.ts

import { Dockest } from 'dockest'
import config from './jest.config.integration.js'

const dockest = new Dockest({
  jestOpts: {
    ...config,
    passWithNoTests: true
})

// Specify the services from the Compose file that should be included in the integration test
const dockestServices = [
  {
    serviceName: 'myRedis', // Must match a service in the Compose file
  },
]

dockest.run(dockestServices)

If your jest config is a function you will have to use the returned config object instead.

daon avatar Nov 23 '20 21:11 daon