Skip to content

Commit

Permalink
test: add a test whether build files are es5 or not
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed May 21, 2020
1 parent 80b9a3c commit 005903b
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 3 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ commands:
- run: yarn audit
- run: yarn lint
- run: yarn test
- run: yarn test:build-assets
# visual regression testing
run-reg-suit:
steps:
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@types/react-transition-group": "^4.2.4",
"@types/styled-components": "^5.1.0",
"babel-loader": "^8.1.0",
"ecma-version-validator-webpack-plugin": "^1.0.4",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4",
Expand All @@ -41,6 +42,7 @@
"husky": "^4.2.5",
"jest": "^25.5.4",
"lint-staged": "^10.2.2",
"memory-fs": "^0.5.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"react": "^16.13.1",
Expand All @@ -61,7 +63,8 @@
"stylelint-processor-styled-components": "^1.10.0",
"ts-jest": "^25.5.1",
"ts-loader": "^7.0.0",
"typescript": "^3.9.2"
"typescript": "^3.9.2",
"webpack": "^4.43.0"
},
"peerDependencies": {
"react": "^16.13.0",
Expand Down Expand Up @@ -121,6 +124,7 @@
"storybook": "start-storybook -p 6006",
"test": "jest",
"test:update-snapshot": "jest --updateSnapshot",
"test:build-assets": "node scripts/build-test.ts",
"test-visual": "reg-suit run"
},
"sideEffects": false,
Expand Down
32 changes: 32 additions & 0 deletions scripts/build-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { ECMAVersionValidatorPlugin } = require('ecma-version-validator-webpack-plugin')
const webpack = require('webpack')
const path = require('path')
const MemoryFS = require('memory-fs')

const compiler = webpack({
mode: 'development',
entry: path.resolve('src', 'index.ts'),
devtool: 'nosources-source-map',
plugins: [new ECMAVersionValidatorPlugin()],
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
},
],
},
})
compiler.outputFileSystem = new MemoryFS()
compiler.run((err, stats) => {
if (err !== null) {
throw err
}
if (stats.compilation.errors.length > 0) {
throw stats.compilation.errors
}
})
Loading

0 comments on commit 005903b

Please sign in to comment.