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

refactor: upgrade babel, migrate to jest #151

Merged
merged 3 commits into from May 18, 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
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -3,5 +3,5 @@ language: node_js
node_js:
- lts/*
after_success:
- "npm run ci"
- "cat artifacts/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
# - "npm run ci"
- "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
113 changes: 3 additions & 110 deletions Gruntfile.js
Expand Up @@ -12,7 +12,6 @@ module.exports = function (grunt) {
'grunt-contrib-clean',
'grunt-contrib-connect',
'grunt-contrib-watch',
'grunt-babel',
'grunt-shell',
'grunt-webpack'
].forEach(function (packageName) {
Expand Down Expand Up @@ -86,69 +85,6 @@ module.exports = function (grunt) {
}]
}
},
// react
// compiles jsx to js
babel: {
dist: {
options: {
sourceMap: false
},
files: [
{
expand: true,
cwd: '<%= project.src %>',
src: ['**/*.*'],
dest: '<%= project.dist %>/',
extDot: 'last',
ext: '.js'
}
]
},
functional: {
options: {
sourceMap: false
},
files: [
{
expand: true,
src: ['<%= project.functional %>/**/*.jsx'],
extDot: 'last',
ext: '.js'
}
]
},
unit: {
files: [
{
expand: true,
src: [
'<%= project.unit %>/**/*.*'
],
dest: '<%= project.tmp %>',
extDot: 'last',
ext: '.js'
}
]
}
},
// shell
// shell commands to run protractor and istanbul
shell: {
istanbul: {
options: {
execOptions: {
env: env
}
},
command: 'node tests/helpers/rAF.js node_modules/istanbul/lib/cli.js cover --dir <%= project.coverage_dir %> ' +
'-- ./node_modules/mocha/bin/_mocha <%= project.tmp %>/<%= project.unit %> ' +
'--recursive --reporter xunit-file'
},
mocha: {
command: './node_modules/mocha/bin/mocha <%= project.tmp %>/<%= project.unit %> ' +
'--recursive --reporter spec'
}
},
// webpack
// create js rollup with webpack module loader for functional tests
webpack: {
Expand All @@ -160,7 +96,7 @@ module.exports = function (grunt) {
module: {
loaders: [
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.jsx$/, loader: require.resolve('babel-loader') },
// { test: /\.jsx$/, loader: require.resolve('babel-loader') },
{ test: /\.json$/, loader: 'json-loader'}
]
}
Expand Down Expand Up @@ -198,7 +134,7 @@ module.exports = function (grunt) {
'saucelabs-mocha': {
all: {
options: {
testname: 'react-i13n func test',
testname: 'react-stickynode func test',
urls: [
'http://127.0.0.1:9999/tests/functional/page.html'
],
Expand All @@ -211,11 +147,6 @@ module.exports = function (grunt) {
},
throttled: 3,
browsers: [
{
browserName: 'internet explorer',
platform: 'Windows 7',
version: '9'
},
{
browserName: 'internet explorer',
platform: 'Windows 8',
Expand Down Expand Up @@ -287,44 +218,6 @@ module.exports = function (grunt) {
'watch:functional'
]);

// cover
// 1. clean tmp/
// 2. compile jsx to js in tmp/
// 3. run istanbul cover in tmp/ using mocha command
// 4. clean tmp/
grunt.registerTask('cover', [
'clean:tmp',
'clean:dist',
'babel:unit',
'babel:dist',
'shell:istanbul',
'clean:tmp'
]);

grunt.registerTask('unit', [
'clean:tmp',
'clean:dist',
'babel:unit',
'babel:dist',
'shell:mocha'
]);

// dist
// 1. clean dist/
// 2. compile jsx to js in dist/
grunt.registerTask('dist', [
'clean:dist',
'babel:dist'
]);

grunt.registerTask('test', [
'clean:dist',
'babel:dist',
'clean:tmp',
'babel:unit',
'shell:mocha'
]);

// default
grunt.registerTask('default', ['dist']);
grunt.registerTask('default', ['functional']);
};
12 changes: 12 additions & 0 deletions babel.config.json
@@ -0,0 +1,12 @@
{
"presets": [
[
"@babel/env",
{
"useBuiltIns": "usage",
"corejs": 3
}
],
'@babel/preset-react'
]
}