Skip to content

Commit 5eff7f6

Browse files
authored
Merge pull request #125 from jgiven/feature/dependency-migration
Feature/dependency migration
2 parents 0b159b8 + 0145277 commit 5eff7f6

13 files changed

+37905
-37737
lines changed

new/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# production
1212
/build
13+
/dist
1314

1415
# misc
1516
.DS_Store
@@ -18,6 +19,7 @@
1819
.env.test.local
1920
.env.production.local
2021

22+
.parcel-cache/
2123
npm-debug.log*
2224
yarn-debug.log*
2325
yarn-error.log*

new/config/jest/SvgComponent.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function SvgComponent() {
2+
return null;
3+
}

new/config/jest/babelTransform.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2014-present, Facebook, Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
// @remove-on-eject-end
9+
"use strict";
10+
11+
const babelJest = require("babel-jest").default;
12+
13+
const hasJsxRuntime = (() => {
14+
if (process.env.DISABLE_NEW_JSX_TRANSFORM === "true") {
15+
return false;
16+
}
17+
18+
try {
19+
require.resolve("react/jsx-runtime");
20+
return true;
21+
} catch (e) {
22+
return false;
23+
}
24+
})();
25+
26+
module.exports = babelJest.createTransformer({
27+
presets: [
28+
[
29+
require.resolve("babel-preset-react-app"),
30+
{
31+
runtime: hasJsxRuntime ? "automatic" : "classic"
32+
}
33+
]
34+
],
35+
babelrc: false,
36+
configFile: false
37+
});

new/config/jest/cssTransform.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2014-present, Facebook, Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
// @remove-on-eject-end
9+
"use strict";
10+
11+
// This is a custom Jest transformer turning style imports into empty objects.
12+
// http://facebook.github.io/jest/docs/en/webpack.html
13+
14+
module.exports = {
15+
process() {
16+
return "module.exports = {};";
17+
},
18+
getCacheKey() {
19+
// The output is always the same.
20+
return "cssTransform";
21+
}
22+
};

new/config/jest/fileTransform.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
3+
const path = require("path");
4+
5+
// This is a custom Jest transformer turning file imports into filenames.
6+
// http://facebook.github.io/jest/docs/en/webpack.html
7+
8+
module.exports = {
9+
process(src, filename) {
10+
const assetFilename = JSON.stringify(path.basename(filename));
11+
return `module.exports = ${assetFilename};`;
12+
}
13+
};

new/jest.config.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"roots": ["<rootDir>/src"],
3+
"collectCoverageFrom": ["src/**/*.{js,jsx,ts,tsx}", "!src/**/*.d.ts"],
4+
"setupFilesAfterEnv": ["<rootDir>/src/setupTests.ts"],
5+
"testMatch": [
6+
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
7+
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
8+
],
9+
"testEnvironment": "jsdom",
10+
"transform": {
11+
"^.+\\.(js|jsx|mjs|cjs|ts|tsx)$": "<rootDir>/config/jest/babelTransform.js",
12+
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
13+
"^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
14+
},
15+
"transformIgnorePatterns": [
16+
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$",
17+
"^.+\\.module\\.(css|sass|scss)$"
18+
],
19+
"modulePaths": [],
20+
"moduleNameMapper": {
21+
"^react-native$": "react-native-web",
22+
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
23+
"^jsx:.+\\.svg": "<rootDir>/config/jest/SvgComponent.js"
24+
},
25+
"moduleFileExtensions": [
26+
"web.js",
27+
"js",
28+
"web.ts",
29+
"ts",
30+
"web.tsx",
31+
"tsx",
32+
"json",
33+
"web.jsx",
34+
"jsx",
35+
"node"
36+
],
37+
"watchPlugins": ["jest-watch-typeahead/filename", "jest-watch-typeahead/testname"],
38+
"resetMocks": true
39+
}

0 commit comments

Comments
 (0)