mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Move Jest test setup to root (#10963)
This commit is contained in:
parent
c6da5f67d6
commit
90be7e882f
10 changed files with 54 additions and 36 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -36,5 +36,4 @@ selenium
|
|||
*.swo
|
||||
*.out
|
||||
ui_framework/doc_site/build/*.js*
|
||||
ui_framework/jest/report
|
||||
yarn.lock
|
||||
|
|
|
@ -63,9 +63,7 @@
|
|||
"mocha": "mocha",
|
||||
"mocha:debug": "mocha --debug-brk",
|
||||
"sterilize": "grunt sterilize",
|
||||
"uiFramework:start": "grunt uiFramework:start",
|
||||
"uiFramework:dev": "node tasks/utils/ui_framework_test --env=jsdom --watch",
|
||||
"uiFramework:coverage": "node tasks/utils/ui_framework_test --env=jsdom --coverage"
|
||||
"uiFramework:start": "grunt uiFramework:start"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -97,7 +95,7 @@
|
|||
"autoprefixer-loader": "2.0.0",
|
||||
"babel-cli": "6.18.0",
|
||||
"babel-core": "6.21.0",
|
||||
"babel-jest": "18.0.0",
|
||||
"babel-jest": "19.0.0",
|
||||
"babel-loader": "6.2.10",
|
||||
"babel-plugin-add-module-exports": "0.2.1",
|
||||
"babel-polyfill": "6.20.0",
|
||||
|
|
15
scripts/jest.js
Executable file
15
scripts/jest.js
Executable file
|
@ -0,0 +1,15 @@
|
|||
// # Run Jest tests
|
||||
//
|
||||
// All args will be forwarded directly to Jest, e.g. to watch tests run:
|
||||
//
|
||||
// node scripts/jest --watch
|
||||
//
|
||||
// or to build code coverage:
|
||||
//
|
||||
// node scripts/jest --coverage
|
||||
//
|
||||
// See all cli options in https://facebook.github.io/jest/docs/cli.html
|
||||
|
||||
require('../src/optimize/babel/register');
|
||||
require('../src/jest/cli');
|
||||
|
6
src/jest/babelTransform.js
Normal file
6
src/jest/babelTransform.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
const babelJest = require('babel-jest');
|
||||
const options = require('../optimize/babel/options');
|
||||
|
||||
const babelOptions = options.webpack;
|
||||
|
||||
module.exports = babelJest.createTransformer(babelOptions);
|
|
@ -1,5 +1,5 @@
|
|||
const jest = require('jest');
|
||||
const config = require('./ui_framework_test_config');
|
||||
import jest from 'jest';
|
||||
import { config } from './config';
|
||||
|
||||
const argv = process.argv.slice(2);
|
||||
|
21
src/jest/config.js
Normal file
21
src/jest/config.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { resolve } from 'path';
|
||||
|
||||
export const config = {
|
||||
roots: ['<rootDir>/ui_framework/'],
|
||||
collectCoverageFrom: [
|
||||
'ui_framework/components/**/*.js',
|
||||
'!ui_framework/components/index.js',
|
||||
'!ui_framework/components/**/*/index.js',
|
||||
],
|
||||
coverageDirectory: '<rootDir>/target/jest-coverage',
|
||||
coverageReporters: ['html'],
|
||||
moduleFileExtensions: ['jsx', 'js', 'json'],
|
||||
testPathIgnorePatterns: [
|
||||
'<rootDir>[/\\\\]ui_framework[/\\\\](dist|doc_site|jest)[/\\\\]'
|
||||
],
|
||||
transform: {
|
||||
'^.+\\.(js|jsx)$': resolve(__dirname, './babelTransform.js')
|
||||
},
|
||||
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
|
||||
snapshotSerializers: ['<rootDir>/node_modules/enzyme-to-json/serializer']
|
||||
};
|
|
@ -28,6 +28,7 @@ module.exports = function (grunt) {
|
|||
'eslint:source',
|
||||
'licenses',
|
||||
'test:server',
|
||||
'test:jest',
|
||||
'test:browser-ci',
|
||||
'test:api',
|
||||
'_build:verifyTranslations',
|
||||
|
|
|
@ -51,9 +51,9 @@ module.exports = function (grunt) {
|
|||
grunt.registerTask('test:coverage', [ 'run:testCoverageServer', 'karma:coverage' ]);
|
||||
|
||||
grunt.registerTask('test:quick', [
|
||||
'uiFramework:test',
|
||||
'test:server',
|
||||
'test:ui',
|
||||
'test:jest',
|
||||
'test:browser',
|
||||
'test:api'
|
||||
]);
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
const platform = require('os').platform();
|
||||
const config = require('./utils/ui_framework_test_config');
|
||||
const { resolve } = require('path');
|
||||
|
||||
module.exports = function (grunt) {
|
||||
grunt.registerTask('uiFramework:test', function () {
|
||||
grunt.registerTask('test:jest', function () {
|
||||
const done = this.async();
|
||||
Promise.all([uiFrameworkTest()]).then(done);
|
||||
runJest().then(done);
|
||||
});
|
||||
|
||||
function uiFrameworkTest() {
|
||||
function runJest() {
|
||||
const serverCmd = {
|
||||
cmd: /^win/.test(platform) ? '.\\node_modules\\.bin\\jest.cmd' : './node_modules/.bin/jest',
|
||||
cmd: 'node',
|
||||
args: [
|
||||
'--env=jsdom',
|
||||
`--config=${JSON.stringify(config)}`,
|
||||
resolve(__dirname, '../scripts/jest.js')
|
||||
],
|
||||
opts: { stdio: 'inherit' }
|
||||
};
|
|
@ -1,20 +0,0 @@
|
|||
const rootDir = 'ui_framework';
|
||||
|
||||
module.exports = {
|
||||
rootDir,
|
||||
collectCoverageFrom: [
|
||||
'components/**/*.js',
|
||||
// Seems to be a bug with jest or micromatch, in which the above glob doesn't match subsequent
|
||||
// levels of directories, making this glob necessary.
|
||||
'components/**/**/*.js',
|
||||
'!components/index.js',
|
||||
'!components/**/*/index.js',
|
||||
],
|
||||
coverageDirectory: '<rootDir>/jest/report',
|
||||
coverageReporters: ['html'],
|
||||
moduleFileExtensions: ['jsx', 'js', 'json'],
|
||||
testPathIgnorePatterns: ['<rootDir>/(dist|doc_site|jest)/'],
|
||||
testEnvironment: 'node',
|
||||
testRegex: '.*\.test\.(js|jsx)$',
|
||||
snapshotSerializers: ['<rootDir>/../node_modules/enzyme-to-json/serializer']
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue