Skip to content

Commit

Permalink
fix(workflow-plugin-react): allow hook into jest setupFiles
Browse files Browse the repository at this point in the history
Closes #162
  • Loading branch information
Rob McGuinness committed Apr 26, 2018
1 parent a550e3a commit d274f4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -38,6 +38,7 @@ npx @availity/workflow init <your-project-name> --package angular

* Files placed in `project/app/static` will automatically get copied to the build directory. This can be useful when an application needs to reference static documents like images and PDFs without having to import them using Webpack. The files would be accessible through the path `static` relative to the application.
* A global variable `APP_VERSION` is written to javascript bundle that can be used to determine the version of the application that was deployed. Open up the browser debugger and type `APP_VERSION`.
* Hook into Jest `setupFiles` by adding `jest.setup.js` at the root of your project

## CLI

Expand Down
9 changes: 8 additions & 1 deletion packages/workflow-plugin-react/test.js
@@ -1,10 +1,17 @@
// https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/utils/createJestConfig.js
const jest = require('jest');
const path = require('path');
const settings = require('@availity/workflow-settings');
const exists = require('exists-sync');

function create() {
const rootDir = settings.project();

const setupFilesPath = path.join(settings.project(), 'jest.setup.js');
const setupFilesExist = exists(setupFilesPath);

const setupFiles = setupFilesExist ? [`${require.resolve(setupFilesPath)}`] : [];

const config = {
collectCoverageFrom: ['project/app/**/*.{js,jsx}'],
coveragePathIgnorePatterns: ['/node_modules/', '/coverage/', '/dist/'],
Expand All @@ -15,7 +22,7 @@ function create() {
'^.+\\.css$': `${require.resolve('./jest/css.js')}`,
'^(?!.*\\.(js|jsx|css|json)$)': `${require.resolve('./jest/file.js')}`
},
setupFiles: [require.resolve('raf/polyfill')],
setupFiles: [require.resolve('raf/polyfill'), ...setupFiles],
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\](?!@availity).+\\.(js|jsx)$'],
testMatch: [
// Ignore the following directories:
Expand Down

0 comments on commit d274f4f

Please sign in to comment.