Skip to content

Commit

Permalink
add unit test for es6
Browse files Browse the repository at this point in the history
  • Loading branch information
yinsang committed Sep 14, 2018
1 parent d8cfb43 commit db12254
Show file tree
Hide file tree
Showing 8 changed files with 11,785 additions and 0 deletions.
3 changes: 3 additions & 0 deletions webpack-babel-unitTest/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [ "es2015" ]
}
17 changes: 17 additions & 0 deletions webpack-babel-unitTest/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!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>
<h2>webpack pack with babel</h2>
<br/>
<h2> include babel,none of other packages.</h2>
<h2>observe does dist/main.js has [...testArr]</h2>
<br/>
<script src="./dist/main.js"></script>
</body>
</html>
7,386 changes: 7,386 additions & 0 deletions webpack-babel-unitTest/package-lock.json

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions webpack-babel-unitTest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "webpack-unit-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha --compilers js:babel-core/register --recursive unit",
"dev": "webpack-dev-server"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.0.1",
"@babel/preset-env": "^7.0.0",
"babel-core": "^6.26.3",
"babel-loader": "^8.0.2",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-register": "^6.26.0",
"chai": "^4.1.2",
"mocha": "^5.2.0",
"webpack": "^4.19.0",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.8"
},
"dependencies": {}
}
3 changes: 3 additions & 0 deletions webpack-babel-unitTest/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default (arg)=>{
return arg
}
11 changes: 11 additions & 0 deletions webpack-babel-unitTest/unit/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import index from './../src'
import {expect} from 'chai'
describe('测试法返回值', ()=>{
it('num', ()=>{
expect(index(3)).to.be.equal(3)
})

it('strr', ()=>{
expect(index('aaa')).to.be.equal('aa')
})
})
11 changes: 11 additions & 0 deletions webpack-babel-unitTest/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader'
}
]
}
}
Loading

0 comments on commit db12254

Please sign in to comment.