Skip to content

Commit

Permalink
test: fixing broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Aug 31, 2020
1 parent 296c7de commit 6257159
Show file tree
Hide file tree
Showing 6 changed files with 1,935 additions and 122 deletions.
10 changes: 10 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
["@babel/preset-env", {
"targets": {
"browsers": ["last 2 versions"]
}
}],
"@babel/preset-react"
]
}
19 changes: 16 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
const config = require('../../jest.config');
const path = require('path');

module.exports = {
...config,
rootDir: './',
coveragePathIgnorePatterns: ['<rootDir>/__tests__/__fixtures__/'],
collectCoverageFrom: [
'**/*.{js,jsx}',
'!lib/*.js',
'!**/node_modules/**',
'!jest.config.js',
'!**/coverage/lcov-report/**',
],
setupFiles: [path.join(__dirname, '/lib/enzyme')],
testPathIgnorePatterns: ['<rootDir>/__tests__/__fixtures__/'],
transform: {
'^.+\\.jsx?$': path.join(__dirname, '/lib/babel-jest'),
},
transformIgnorePatterns: [
// Since `@readme/variable` doesn't ship any transpiled code, we need to transform it as we're running tests.
'<rootDir>/node_modules/@readme/variable/^.+\\.jsx?$',
],
};
6 changes: 6 additions & 0 deletions lib/babel-jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true }] */
const babelJest = require('babel-jest');
const path = require('path');
const babelRc = JSON.parse(require('fs').readFileSync(path.join(__dirname, '..', '.babelrc'), 'utf8'));

module.exports = babelJest.createTransformer(babelRc);
7 changes: 7 additions & 0 deletions lib/enzyme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
const Adapter = require('enzyme-adapter-react-16');
const enzyme = require('enzyme');

require('babel-polyfill');

enzyme.configure({ adapter: new Adapter() });
Loading

0 comments on commit 6257159

Please sign in to comment.