Skip to content

Commit 06e59bb

Browse files
authored
Merge pull request #11 from ilyasudakov/develop
Fix typescript jest config
2 parents 3b91b87 + 0c961ee commit 06e59bb

File tree

9 files changed

+50
-21
lines changed

9 files changed

+50
-21
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# ignore generated modules/files
22
/node_modules/
3+
/.vscode/
34
package-lock.json
45
/coverage/
56
public/*

bin/setup.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ function copyTypeScriptFiles() {
125125
shell.cp('bin/typescript/webpack.prod.ts', 'webpack.prod.ts');
126126
shell.cp('bin/typescript/.eslintrc.js', '.eslintrc.js');
127127
shell.cp('bin/typescript/App.tsx', 'src/components/App.tsx');
128+
shell.cp('bin/typescript/App.test.js', 'src/components/App.test.js');
129+
shell.cp(
130+
'bin/typescript/jest.config.js',
131+
'jest.config.js',
132+
);
128133
shell.cp('bin/typescript/index.tsx', 'src/index.tsx');
129134
resolve();
130135
} catch (err) {

bin/typescript/App.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { render } from '@testing-library/react';
2+
import { App } from './App.tsx';
3+
4+
describe('App component', () => {
5+
test('renders', () => {
6+
const { getByText } = render(<App />);
7+
expect(getByText('App')).toBeInTheDocument();
8+
});
9+
});

bin/typescript/App.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export const App: React.FC = () => {
2-
return <div>MyApp</div>;
3-
};
4-
2+
return <div>MyApp</div>;
3+
};

bin/typescript/jest.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
roots: ['<rootDir>/src'],
3+
transform: {
4+
'^.+\\.tsx?$': 'ts-jest',
5+
},
6+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
7+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
8+
testPathIgnorePatterns: ['/node_modules/', '/public/'],
9+
setupFilesAfterEnv: [
10+
'./src/setupTests.js',
11+
'@testing-library/jest-dom/extend-expect',
12+
],
13+
};

bin/typescript/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "basic_react_boilerplate",
2+
"name": "react-base",
33
"version": "1.0.0",
4-
"description": "React + Webpack 5 + SCSS + Jest/RTL",
4+
"description": "Simple React boilerplate with TS or JS - its your choice, Webpack 5, Jest/RTL, Axios&React-Query, ESLint&Prettier and more",
55
"main": "index.tsx",
66
"repository": {
77
"type": "git",
8-
"url": "git://github.com/ilyasudakov/basic-react-boilerplate.git"
8+
"url": "git://github.com/ilyasudakov/react-base.git"
99
},
1010
"scripts": {
1111
"start": "webpack serve",
@@ -30,6 +30,8 @@
3030
"typescript": "^4.1.3",
3131
"@types/webpack": "^4.41.26",
3232
"ts-node": "^9.1.1",
33+
"@types/jest": "^26.0.20",
34+
"ts-jest": "^26.5.0",
3335
"@babel/core": "^7.12.10",
3436
"@babel/preset-env": "^7.12.11",
3537
"@babel/preset-react": "^7.12.10",

bin/typescript/tsconfig.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"compilerOptions": {
3-
"outDir": "./public/",
4-
"noImplicitAny": true,
5-
"target": "es5",
6-
"lib": ["es5", "es6", "dom"],
7-
"jsx": "react-jsx",
8-
"allowJs": true,
9-
"moduleResolution": "node",
10-
"allowSyntheticDefaultImports": true,
11-
}
12-
}
2+
"compilerOptions": {
3+
"outDir": "./public/",
4+
"noImplicitAny": true,
5+
"target": "es5",
6+
"lib": ["es5", "es6", "dom"],
7+
"jsx": "react-jsx",
8+
"allowJs": true,
9+
"moduleResolution": "node",
10+
"allowSyntheticDefaultImports": true
11+
}
12+
}

bin/typescript/webpack.prod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const config: webpack.Configuration = {
1111
mode: "production",
1212
entry: "./src/index.tsx",
1313
output: {
14-
path: path.resolve(__dirname, "dist"),
14+
path: path.resolve(__dirname, "public"),
1515
filename: "bundle.js"
1616
},
1717
resolve: {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "basic_react_boilerplate",
2+
"name": "react-base",
33
"version": "1.0.0",
4-
"description": "React + Webpack 5 + SCSS + Jest/RTL",
4+
"description": "Simple React boilerplate with TS or JS - its your choice, Webpack 5, Jest/RTL, Axios&React-Query, ESLint&Prettier and more",
55
"main": "index.js",
66
"repository": {
77
"type": "git",
8-
"url": "git://github.com/ilyasudakov/basic-react-boilerplate.git"
8+
"url": "git://github.com/ilyasudakov/react-base.git"
99
},
1010
"scripts": {
1111
"start": "webpack serve",

0 commit comments

Comments
 (0)