Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de376b9

Browse files
author
Gonzalo Diaz
committed
[BUGFIX] jest upgrade fixes:
* Babel for ESLint import assertion: * https://stackoverflow.com/a/73225592 * https://stackoverflow.com/a/72167806 * DISABLE instanbul for inspecting JSON imports * facebook/create-react-app#6106 (comment)
1 parent ffcfe00 commit de376b9

9 files changed

+156
-8
lines changed

.babelrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"plugins": [
3+
"@babel/plugin-syntax-import-assertions"
4+
]
5+
}

.eslintrc

+9-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@
2222
"jest/globals": true
2323
},
2424

25+
"parser": "@babel/eslint-parser",
26+
2527
"parserOptions": {
26-
"ecmaVersion": 2020,
27-
"sourceType": "module"
28+
"ecmaVersion": 2022,
29+
"sourceType": "module",
30+
"babelOptions": {
31+
"parserOpts": {
32+
"plugins": ["importAssertions"]
33+
}
34+
}
2835
},
2936

3037
"globals": {

jest.config.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ const jestConfig = {
1616
'lcov',
1717
['text', { 'skipFull': false }]
1818
],
19-
'testPathIgnorePatterns': ['/node_modules/', '<rootDir>/coverage'],
2019
'coverageDirectory': 'coverage/',
21-
'testMatch': ['**/?(*.)+(spec|test).js?(x)']
20+
'collectCoverageFrom': ['src/**/*.{js,jsx,ts}', '!src/**/*.tsx'],
21+
'testPathIgnorePatterns': ['/node_modules/', '<rootDir>/coverage'],
22+
'testMatch': ['**/?(*.)+(spec|test).js?(x)'],
23+
'transform': {
24+
'^.+\\.(js|jsx)$': 'babel-jest'
25+
}
2226
};
2327

2428
if (BRUTEFORCE) {

package-lock.json

+130
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
"license": "MIT",
2121
"type": "module",
2222
"devDependencies": {
23+
"@babel/eslint-parser": "^7.19.1",
24+
"@babel/plugin-syntax-import-assertions": "^7.20.0",
2325
"concurrently": "7.6.0",
2426
"eslint": "8.33.0",
2527
"eslint-config-airbnb-base": "15.0.0",

src/problem0011.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import logger from './logger.js';
3636

3737
import { problem0011 } from './problem0011.js';
3838

39-
import matrix from './data/problem0011.json';
39+
import matrix from './data/problem0011.json' assert { type: 'json' };
4040

4141
describe('problem 0011', () => {
4242
it('problem 0011 solution found', () => {

src/problem0013.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import logger from './logger.js';
1212

1313
import { problem0013 } from './problem0013.js';
14-
import inputNums from './data/problem0013.json';
14+
import inputNums from './data/problem0013.json' assert { type: 'json' };
1515

1616
describe('problem 0013', () => {
1717
it('problem 0013 solution found', () => {

src/problem0018.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import logger from './logger.js';
4545

4646
import { problem0018 } from './problem0018.js';
47-
import inputTriangle from './data/problem0018.json';
47+
import inputTriangle from './data/problem0018.json' assert { type: 'json' };
4848

4949
describe('problem 0018', () => {
5050
it('problem 0018 solution found', () => {

src/problem0022.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import logger from './logger.js';
3030

3131
import { problem0022 } from './problem0022.js';
3232

33-
import inputNames from './data/p022_names.json';
33+
import inputNames from './data/p022_names.json' assert { type: 'json' };
3434

3535
describe('problem 0022', () => {
3636
it('problem 0022 solution found', () => {

0 commit comments

Comments
 (0)