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

Allow hook into Jest setup files #162

Closed
robmcguinness opened this issue Apr 20, 2018 · 2 comments
Closed

Allow hook into Jest setup files #162

robmcguinness opened this issue Apr 20, 2018 · 2 comments

Comments

@robmcguinness
Copy link
Contributor

Some projects like to use https://github.com/airbnb/enzyme which requires a gloabl jest configuration:

const { configure } = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');

configure({ adapter: new Adapter() });

A clean way to add this configuration is through Jest's setupFiles configuration property: https://github.com/Availity/availity-workflow/blob/master/packages/workflow-plugin-react/test.js#L18

Maybe a convention based approach could work where each workflow plugin can detect a jestSetup.js file at the root of the project and include if found:

setupFiles: ['raf/polyfill', '<rootDir>/jestSetup.js'],
@robmcguinness
Copy link
Contributor Author

Having the flag --runInBand is recommend by VS Code to prevent creating a worker pool of child processes.

function unit() {
  const argv = process.argv.slice(2);
  const jestConfig = JSON.stringify(create());
  argv.push(`--config=${jestConfig}`);
  argv.push('--env=jsdom');
  argv.push('--runInBand');

  jest.run(argv);

  return Promise.resolve();
}

@TheSharpieOne
Copy link
Collaborator

Probably also want to give access to setupTestFrameworkScriptFile for react at least (angular currently does this to set up angular and angular-mocks)

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

2 participants