Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add a test whether build files are es5 or not #779

Merged
merged 6 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 --groups dependencies
- 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.4.0",
"@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.5.0",
Expand All @@ -41,6 +42,7 @@
"husky": "^4.2.5",
"jest": "^26.0.1",
"lint-staged": "^10.2.9",
"memory-fs": "^0.5.0",
Copy link
Contributor Author

@koba04 koba04 May 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memory-fs is already deprecated. We can use memfs instead, but an error occurred at an internal of memfs when we use it, so I use memory-fs temporarily. Here is the log that I used memfs.
https://circleci.com/gh/kufu/smarthr-ui/5966

I'll investigate this later.

"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": "^26.1.0",
"ts-loader": "^7.0.5",
"typescript": "^3.9.5"
"typescript": "^3.9.5",
"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
}
})