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

ci: allow to start jest config for all project at once #447

Merged
merged 1 commit into from
May 3, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
const sharedConfig = require('./script/test/jest.base.js');

module.exports = {
...sharedConfig,
clearMocks: true,
verbose: false,

setupFilesAfterEnv: ['./script/test/jest-setup.ts'],
projects: ['<rootDir>/packages/zapp/console', '<rootDir>/packages/plugins/components'],

coverageDirectory: '<rootDir>/.coverage',
collectCoverageFrom: ['**/*.{ts,tsx}', '!**/*/*.stories.{ts,tsx}', '!**/*/*.mocks.{ts,tsx}'],
coveragePathIgnorePatterns: [...sharedConfig.coveragePathIgnorePatterns],
coverageReporters: ['text', 'json', 'html'],
};
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
"build:storybook": "build-storybook",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"storybook": "start-storybook -p 6006",
"test": "cd packages/zapp/console && yarn test && cd ../../../",
"test-coverage": "bash -c 'pushd packages/zapp/console && yarn test-coverage && popd'"
"test": "NODE_ENV=test jest",
"test:clear": "jest --clearCache",
"test-coverage": "NODE_ENV=test jest --coverage"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -54,6 +55,11 @@
"@storybook/manager-webpack5": "^6.4.19",
"@storybook/react": "^6.4.19",
"@storybook/testing-library": "^0.0.9",
"@testing-library/jest-dom": "^5.5.0",
"@testing-library/react": "^10.0.3",
"@testing-library/react-hooks": "^7.0.2",
"ts-jest": "^26.3.0",
"jest": "^26.0.0",
"react-hot-loader": "^4.1.2"
}
}
6 changes: 6 additions & 0 deletions packages/plugins/components/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
const sharedConfig = require('../../../script/test/jest.base.js');

module.exports = {
...sharedConfig,
};
4 changes: 3 additions & 1 deletion packages/plugins/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "./dist/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/esm/index.d.ts",
"license": "Apache-2.0",
"private": false,
"publishConfig": {
"access": "public",
Expand All @@ -13,7 +14,8 @@
"scripts": {
"build": "yarn build:esm && yarn build:cjs",
"build:esm": "tsc --module esnext --outDir lib/esm",
"build:cjs": "tsc"
"build:cjs": "tsc",
"test": "NODE_ENV=test jest"
},
"dependencies": {
"@material-ui/core": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/components/src/NavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const NavBar = (props: NavBarProps) => {
elevation={0}
id="navbar"
position="fixed"
className={props.className}
className={props.className as string}
>
<Toolbar id={navBarContentId}>
{/* {content} */}
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/components/src/NavBar/navbar.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { render, screen } from '@testing-library/react';
import { NavBar, add } from './index';

Expand All @@ -10,7 +10,7 @@ describe('add function', () => {

it('NavBar contains correct text', () => {
render(<NavBar />);
const text = screen.getByText("It's me - Navigation Bar");
const text = screen.getByText('NASTYA IS HERE');
anrusina marked this conversation as resolved.
Show resolved Hide resolved
expect(text).toBeInTheDocument();
});
});
36 changes: 12 additions & 24 deletions packages/zapp/console/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,28 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
const sharedConfig = require('../../../script/test/jest.base.js');

module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
...sharedConfig,
testPathIgnorePatterns: ['__stories__', '.storybook', 'node_modules', 'dist', 'build'],
setupFilesAfterEnv: ['<rootDir>/src/test/setupTests.ts'],
clearMocks: true,
verbose: false,

moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'node'],
modulePaths: ['<rootDir>/src'],
roots: ['<rootDir>/src'],
transformIgnorePatterns: ['<rootDir>/node_modules/(?!@flyteorg/flyteidl)', 'protobufjs/minimal'],
transform: {
'^.+\\.(j|t)sx?$': 'ts-jest',
},

moduleNameMapper: {
'@flyteconsole/(.*)': [
'<rootDir>/../../../packages/plugins/$1/src',
'<rootDir>/../../../packages/zapp/$1/src',
],
...sharedConfig.moduleNameMapper,
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/assetsTransformer.js',
},

coverageDirectory: '../../../.coverage',
collectCoverageFrom: ['**/*.{ts,tsx}', '!**/*/*.stories.{ts,tsx}', '!**/*/*.mocks.{ts,tsx}'],
coveragePathIgnorePatterns: [
...sharedConfig.coveragePathIgnorePatterns,
'__stories__',
'__mocks__',
'<rootDir>/.storybook',
'<rootDir>/node_modules',
'<rootDir>/dist',
'<rootDir>/build',
'<rootDir>/src/tsd',
'<rootDir>/src/server.ts',
'<rootDir>/.eslintrc.js',
'\\.config.js$',
'src/components/App.tsx',
'src/tsd',
'src/client.tsx',
'src/protobuf.ts',
'src/server.ts',
],
coverageReporters: ['text', 'json', 'html'],
};
10 changes: 1 addition & 9 deletions packages/zapp/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"fix": "yarn lint --fix && yarn format",
"mockApi": "node ./mockApi",
"tdd": "yarn run test --watch --verbose false",
"test": "NODE_ENV=test jest --config=jest.config.js",
"test-coverage": "NODE_ENV=test jest --coverage --config=jest.config.js"
"test": "NODE_ENV=test jest"
},
"keywords": [
"react",
Expand Down Expand Up @@ -74,15 +73,11 @@
"@semantic-release/github": "^7.0.5",
"@semantic-release/npm": "^7.0.5",
"@semantic-release/release-notes-generator": "^9.0.1",
"@testing-library/jest-dom": "^5.5.0",
"@testing-library/react": "^10.0.3",
"@testing-library/react-hooks": "^7.0.2",
"@types/cheerio": "^0.22.2",
"@types/d3-shape": "^1.2.6",
"@types/debug": "^0.0.30",
"@types/dom-helpers": "^3.4.1",
"@types/express": "^4.17.2",
"@types/jest": "^26.0.0",
"@types/js-yaml": "^3.10.1",
"@types/linkify-it": "^2.1.0",
"@types/lodash": "^4.14.68",
Expand All @@ -108,7 +103,6 @@
"axios": "^0.21.2",
"axios-mock-adapter": "^1.16.0",
"babel-core": "^7.0.0-0",
"babel-jest": "^26.0.0",
"babel-loader": "^8.2.3",
"camelcase-keys": "^6.1.1",
"classnames": "^2.3.1",
Expand All @@ -133,7 +127,6 @@
"html-webpack-plugin": "^5.5.0",
"husky": "^4.2.5",
"intersection-observer": "^0.7.0",
"jest": "^26.0.0",
"linkify-it": "^2.2.0",
"lint-staged": "^7.0.4",
"lossless-json": "^1.0.3",
Expand Down Expand Up @@ -161,7 +154,6 @@
"shallowequal": "^1.1.0",
"snakecase-keys": "^3.1.0",
"source-map-loader": "^3.0.1",
"ts-jest": "^26.3.0",
"ts-loader": "^9.2.6",
"ts-node": "^8.0.2",
"typescript": "^4.6.2",
Expand Down
1 change: 1 addition & 0 deletions script/test/jest-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom';
16 changes: 16 additions & 0 deletions script/test/jest.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['../../../script/test/jest-setup.ts'],
testPathIgnorePatterns: ['dist', 'node_modules', 'lib'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'node'],
transform: {
'^.+\\.(j|t)sx?$': 'ts-jest',
},

moduleNameMapper: {
'@flyteconsole/(.*)': ['<rootDir>/packages/plugins/$1/src', '<rootDir>/packages/zapp/$1/src'],
},

coveragePathIgnorePatterns: ['mocks', 'src/index'],
};
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4091,7 +4091,7 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/jest@*", "@types/[email protected]", "@types/jest@^26.0.0":
"@types/jest@*", "@types/[email protected]":
version "26.0.16"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.16.tgz#b47abd50f6ed0503f589db8e126fc8eb470cf87c"
integrity sha512-Gp12+7tmKCgv9JjtltxUXokohCAEZfpJaEW5tn871SGRp8I+bRWBonQO7vW5NHwnAHe5dd50+Q4zyKuN35i09g==
Expand Down Expand Up @@ -5529,7 +5529,7 @@ babel-core@^7.0.0-0:
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
integrity sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg==

babel-jest@^26.0.0, babel-jest@^26.6.3:
babel-jest@^26.6.3:
version "26.6.3"
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-26.6.3.tgz#d87d25cb0037577a0c89f82e5755c5d293c01056"
integrity sha512-pl4Q+GAVOHwvjrck6jKjvmGhnO3jHX/xuB9d27f+EJZ/6k+6nMuPjorrYp7s++bKKdANwzElBWnLWaObvTnaZA==
Expand Down