Skip to content

Commit

Permalink
support for running acceptance tests from vscode
Browse files Browse the repository at this point in the history
vscode extension uses the root jest.config.js file, so that file should support acceptance tests too, not only units. This commit creates two different jest projects (unit and acceptance) and a root jest.config.js that group both projects (#19)
  • Loading branch information
atabel authored Jun 10, 2020
1 parent 96e07c7 commit 0dbf971
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
4 changes: 1 addition & 3 deletions jest.acceptance.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

const jestConfigBase = require('./jest.config');

module.exports = {
...jestConfigBase,
...require('./jest.base.config'),
displayName: 'acceptance',
maxConcurrency: 1,
testTimeout: 30000,
Expand Down
15 changes: 15 additions & 0 deletions jest.base.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @flow
/* eslint-disable filenames/match-regex */

const config /* : any */ = {
// Automatically restore mock state between every test
restoreMocks: true,
collectCoverageFrom: [
'**/src/**/*.js',
'!**/node_modules/**',
'!**/__*__/**', // ignore tests, acceptance, stories, etc
],
coverageReporters: ['json-summary', 'lcov'],
};

module.exports = config;
27 changes: 3 additions & 24 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
// @flow
/* eslint-disable filenames/match-regex */

const config /* : any */ = {
// Automatically restore mock state between every test
restoreMocks: true,

testMatch: ['**/__tests__/*-test.js'],
collectCoverageFrom: [
'**/src/**/*.js',
'!**/node_modules/**',
'!**/__*__/**', // ignore tests, acceptance, stories, etc
],

coverageReporters: ['json-summary', 'lcov'],

testURL: 'http://test.tuenti.com',

// transform: {
// '^.+\\.js$': require.resolve('./src/babel-jest-transformer'),
// },

// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: [require.resolve('./setup-test-env'), '@testing-library/jest-dom/extend-expect'],
module.exports = {
...require('./jest.base.config'),
projects: ['<rootDir>/jest.unit.config.js', '<rootDir>/jest.acceptance.config.js'],
};

module.exports = config;
12 changes: 12 additions & 0 deletions jest.unit.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @flow
/* eslint-disable filenames/match-regex */

const config /* : any */ = {
...require('./jest.base.config'),
displayName: 'unit',
testMatch: ['**/__tests__/*-test.js'],
testURL: 'http://test.tuenti.com',
setupFilesAfterEnv: [require.resolve('./setup-test-env'), '@testing-library/jest-dom/extend-expect'],
};

module.exports = config;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"css/*"
],
"scripts": {
"test": "jest",
"test": "jest --config jest.unit.config.js",
"test-acceptance": "cross-env SCREENSHOT=1 HEADLESS=1 yarn test-acceptance-ui",
"test-acceptance-ui": "jest --config jest.acceptance.config.js",
"prettier-check": "prettier --check '**/*.js' '**/*.json'",
"lint": "eslint --report-unused-disable-directives .",
"prebuild": "yarn clean",
Expand All @@ -22,8 +24,6 @@
"playroom": "playroom start",
"now-build": "yarn storybook-static && ./node_modules/.bin/playroom build",
"storybook-static": "rimraf public && yarn build-storybook -o public --quiet",
"test-acceptance": "cross-env SCREENSHOT=1 HEADLESS=1 yarn test-acceptance-ui",
"test-acceptance-ui": "jest --config jest.acceptance.config.js",
"up-chromium": "docker-compose up -d chromium"
},
"browserslist": [
Expand Down

1 comment on commit 0dbf971

@github-actions
Copy link

Choose a reason for hiding this comment

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

Deploy preview for mistica-web ready!

Built with commit 0dbf971

https://mistica-web-r0fygexj6.now.sh

Please sign in to comment.