-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yinpeng.wyp
committed
Feb 23, 2023
1 parent
3e3ac75
commit c4c93d8
Showing
17 changed files
with
271 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
|
||
presets: [['@babel/preset-env', {targets: {node: 'current'}}], | ||
'@babel/preset-react', | ||
// '@babel/preset-typescript', | ||
], | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script src="./dist/main.js"></script> | ||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "react-webpack", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "jest", | ||
"w": "jest --watch", | ||
"dev": "webpack-dev-server --config webpack.dev.config.js" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"jest": { | ||
"transform": { | ||
"\\.[jt]sx?$": "babel-jest" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.0.1", | ||
"@babel/preset-env": "^7.0.0", | ||
"@babel/preset-react": "^7.0.0", | ||
"babel-jest": "^26.6.3", | ||
"babel-loader": "^8.0.2", | ||
"enzyme": "^3.6.0", | ||
"enzyme-adapter-react-16": "^1.5.0", | ||
"eslint": "^5.5.0", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-html": "^4.0.5", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-node": "^7.0.1", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"jest": "^26.6.3", | ||
"mocha": "^5.2.0", | ||
"react-test-renderer": "^17.0.2", | ||
"webpack": "^4.16.3", | ||
"webpack-cli": "^3.1.0", | ||
"webpack-dev-server": "^3.1.8", | ||
"webpack-merge": "^4.1.4" | ||
}, | ||
"dependencies": { | ||
"react": "^16.5.0", | ||
"react-dom": "^16.5.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
function add (a,b){ | ||
return a+b | ||
} | ||
// describe('describe order', ()=>{ | ||
// console.log(1); | ||
// describe('add', ()=>{ | ||
// console.log(2); | ||
// }) | ||
|
||
// it('it ', ()=>{ | ||
// console.log(3); | ||
// expect(add(1,2)).toBe(3) | ||
// console.log(4); | ||
// }) | ||
// console.log(5); | ||
// }) | ||
// describe.each() | ||
// describe('add', ()=>{ | ||
// it('it ', ()=>{ | ||
// expect(add(1,2)).toBe(3) | ||
// }) | ||
// }) | ||
// describe.each([ | ||
// [1, 1, 2], | ||
// [1, 2, 3], | ||
// [2, 2, 4], | ||
// ])('.add(%i, %j)', (a, b, expected) => { | ||
// // console.log(a,b,expected); | ||
// test('a',()=>{ | ||
// expect(a+b).toBe(expected) | ||
// }) | ||
// }); | ||
// describe.skip('my beverage', () => { | ||
// console.log('firest desc'); | ||
// test('is delicious', () => { | ||
// console.log('first'); | ||
// expect(add(1,2)).toBe(3); | ||
// }); | ||
|
||
// test('is not sour', () => { | ||
// console.log('object'); | ||
// expect(add(1,23)).toBe(24); | ||
// }); | ||
// test.todo('todo sth') | ||
// }); | ||
// describe('my other beverage', () => { | ||
// console.log('after'); | ||
|
||
// test('is not souraaaaa', () => { | ||
// console.log('object33'); | ||
// expect(add(1,23)).toBe(24); | ||
// }); | ||
// // ... will be skipped | ||
// }); | ||
describe('study jest', () => { | ||
test('result white also be a constructor', () => { | ||
const fn = jest.fn((val)=>{ | ||
return val*2 | ||
}) | ||
fn(2) | ||
// this underline make expect wrong | ||
var f = new fn(); | ||
expect(fn.mock.results).toEqual([{ | ||
type: 'return', | ||
value: 4, | ||
}]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /.jsx?$/, | ||
use: { | ||
loader: 'babel-loader' | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const merge = require('webpack-merge') | ||
const webpackBase = require('./webpack.config') | ||
module.exports = merge(webpackBase, { | ||
mode: 'development', | ||
output: { | ||
filename: 'dist/main.js' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import React from 'react' | ||
export default (props)=>{ | ||
<div> | ||
return ( | ||
<div> | ||
{props.children} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.is-invalid{ | ||
color:red | ||
} | ||
.is-invalid~.validationError { | ||
display: inline !important; | ||
// color:red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
react-webpack-eslint-Jest-unitTest/unit/test/study.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
function add (a,b){ | ||
return a+b | ||
} | ||
import axios from 'axios' | ||
jest.mock('axios'); | ||
describe('study jest', () => { | ||
test('result white also be a constructor', () => { | ||
const mockFn = jest.fn((val)=>val); | ||
// console.log(mockFn()); | ||
|
||
// const a = new mockFn(); | ||
// const b = new mockFn(); | ||
mockFn(222) | ||
|
||
expect(mockFn.mock.calls).toEqual([[222]]) | ||
// expect(mockFn.mock.instances[1] === b).toBeTruthy() | ||
mockFn.mockReset() | ||
// expect(mockFn.mock.calls).toEqual([[222]]) | ||
// console.log(mockFn.mock.instances); | ||
console.log('bb', mockFn()); | ||
// expect(mockFn.mock.instances[0] === a).toBeTruthy() | ||
// expect(mockFn.mock.instances[1] === b).toBeTruthy() | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters