Skip to content

Commit

Permalink
Separate jest configs of all examples into their projects
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-dv committed Nov 8, 2018
1 parent 58d269e commit 2fce397
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 52 deletions.
13 changes: 13 additions & 0 deletions examples/angular-cli/jest.addon-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
coveragePathIgnorePatterns: ['/jest-config/', '/node_modules/'],
preset: 'jest-preset-angular',
setupTestFrameworkScriptFile: './jest-config/setup.ts',
snapshotSerializers: [
'<rootDir>/../../node_modules/jest-preset-angular/AngularSnapshotSerializer.js',
'<rootDir>/../../node_modules/jest-preset-angular/HTMLCommentSerializer.js',
],
testPathIgnorePatterns: ['/node_modules/', '/storybook-static/', 'angularshots.test.js', 'dist'],
transform: {
'^.+\\.(ts|js|html)$': '<rootDir>/../../node_modules/jest-preset-angular/preprocessor.js',
},
};
15 changes: 15 additions & 0 deletions examples/angular-cli/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const config = require('../../jest.config');

module.exports = {
...config,
globals: {
__TRANSFORM_HTML__: true,
},
roots: [__dirname],
transform: {
...config.transform,
'^.+[/\\\\].storybook[/\\\\]config\\.ts$': '<rootDir>/scripts/jest-ts-babel.js',
'^.+\\.(ts|html)$': '<rootDir>/node_modules/jest-preset-angular/preprocessor.js',
},
moduleFileExtensions: [...config.moduleFileExtensions, 'ts', 'tsx', 'html'],
};
23 changes: 1 addition & 22 deletions examples/angular-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,9 @@
"storybook:prebuild": "npm run test:generate-output",
"test": "jest",
"test:coverage": "jest --coverage",
"test:generate-output": "jest --json --outputFile=addon-jest.testresults.json || true",
"test:generate-output": "jest --json --config=jest.addon-config.js --outputFile=addon-jest.testresults.json || true",
"test:watch": "jest --watch"
},
"jest": {
"coveragePathIgnorePatterns": [
"/jest-config/",
"/node_modules/"
],
"preset": "jest-preset-angular",
"setupTestFrameworkScriptFile": "./jest-config/setup.ts",
"snapshotSerializers": [
"<rootDir>/../../node_modules/jest-preset-angular/AngularSnapshotSerializer.js",
"<rootDir>/../../node_modules/jest-preset-angular/HTMLCommentSerializer.js"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/storybook-static/",
"angularshots.test.js",
"dist"
],
"transform": {
"^.+\\.(ts|js|html)$": "<rootDir>/../../node_modules/jest-preset-angular/preprocessor.js"
}
},
"dependencies": {
"@angular/common": "^7.0.1",
"@angular/compiler": "^7.0.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/cra-kitchen-sink/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ const config = require('../../jest.config');

module.exports = {
...config,
roots: ['./'],
roots: [__dirname],
moduleDirectories: ['node_modules', 'src'],
};
11 changes: 11 additions & 0 deletions examples/html-kitchen-sink/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const config = require('../../jest.config');

module.exports = {
...config,
roots: [__dirname],
transform: {
...config.transform,
'.*\\.(html)$': '<rootDir>/node_modules/jest-raw-loader',
},
moduleFileExtensions: [...config.moduleFileExtensions, 'html'],
};
16 changes: 16 additions & 0 deletions examples/riot-kitchen-sink/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const config = require('../../jest.config');

module.exports = {
...config,
roots: [__dirname],
moduleNameMapper: {
...config.moduleNameMapper,
'^riot$': 'riot/riot',
},
transform: {
...config.transform,
'^.+\\.(tag)$': '<rootDir>/node_modules/riot-jest-transformer',
'^.+\\.(txt)$': '<rootDir>/node_modules/jest-raw-loader',
},
moduleFileExtensions: [...config.moduleFileExtensions, 'tag'],
};
11 changes: 11 additions & 0 deletions examples/svelte-kitchen-sink/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const config = require('../../jest.config');

module.exports = {
...config,
roots: [__dirname],
transform: {
...config.transform,
'.*\\.(svelte)$': '<rootDir>/node_modules/svelte-jest',
},
moduleFileExtensions: [...config.moduleFileExtensions, 'svelte'],
};
11 changes: 11 additions & 0 deletions examples/vue-kitchen-sink/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const config = require('../../jest.config');

module.exports = {
...config,
roots: [__dirname],
transform: {
...config.transform,
'.*\\.(vue)$': '<rootDir>/node_modules/jest-vue-preprocessor',
},
moduleFileExtensions: [...config.moduleFileExtensions, 'vue'],
};
39 changes: 10 additions & 29 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
module.exports = {
globals: {
__TRANSFORM_HTML__: true,
},
cacheDirectory: '.cache/jest',
clearMocks: true,
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/__mocks__/fileMock.js',
'\\.(css|scss)$': '<rootDir>/__mocks__/styleMock.js',
'\\.(md)$': '<rootDir>/__mocks__/htmlMock.js',
'^riot$': 'riot/riot',
},
projects: ['<rootDir>', '<rootDir>/examples/cra-kitchen-sink'],
projects: [
'<rootDir>',
'<rootDir>/examples/cra-kitchen-sink',
'<rootDir>/examples/html-kitchen-sink',
'<rootDir>/examples/riot-kitchen-sink',
'<rootDir>/examples/svelte-kitchen-sink',
'<rootDir>/examples/vue-kitchen-sink',
'<rootDir>/examples/angular-cli',
],
roots: [
'<rootDir>/addons',
'<rootDir>/app',
'<rootDir>/lib',
'<rootDir>/examples/vue-kitchen-sink',
'<rootDir>/examples/svelte-kitchen-sink',
'<rootDir>/examples/riot-kitchen-sink',
'<rootDir>/examples/html-kitchen-sink',
'<rootDir>/examples/official-storybook',
'<rootDir>/examples/ember-cli',
'<rootDir>/examples/angular-cli',
],
snapshotSerializers: ['@emotion/snapshot-serializer'],
transform: {
'^.+\\.jsx?$': '<rootDir>/scripts/babel-jest.js',
'^.+[/\\\\].storybook[/\\\\]config\\.ts$': '<rootDir>/scripts/jest-ts-babel.js',
'^.+\\.(ts|html)$': '<rootDir>/node_modules/jest-preset-angular/preprocessor.js',
'.*\\.(vue)$': '<rootDir>/node_modules/jest-vue-preprocessor',
'.*\\.(svelte)$': '<rootDir>/node_modules/svelte-jest',
'^.+\\.(tag)$': '<rootDir>/node_modules/riot-jest-transformer',
'^.+\\.(txt)$': '<rootDir>/node_modules/jest-raw-loader',
},
testPathIgnorePatterns: ['/node_modules/', '/dist/', 'addon-jest.test.js', '/cli/test/'],
collectCoverage: false,
Expand All @@ -50,16 +42,5 @@ module.exports = {
setupFiles: ['raf/polyfill'],
testURL: 'http://localhost',
modulePathIgnorePatterns: ['/dist/.*/__mocks__/'],
moduleFileExtensions: [
'ts',
'tsx',
'js',
'jsx',
'json',
'node',
'.html',
'.svelte',
'vue',
'tag',
],
moduleFileExtensions: ['js', 'jsx', 'json', 'node'],
};

0 comments on commit 2fce397

Please sign in to comment.