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

feat: unit test infrastructure #313

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 24 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const {pathsToModuleNameMapper} = require('ts-jest/utils')

const {compilerOptions} = require('./tsconfig')

module.exports = {
preset: 'ts-jest',
globals: {
'ts-jest': {
'tsConfig': './tsconfig.json',
},
},
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
transformIgnorePatterns: ['/node_modules/(?!@qiwi).+ \\ .js $'],
testMatch: ['**/test/**/*.+(ts|tsx)'],
collectCoverage: true,
snapshotSerializers: ['enzyme-to-json/serializer'],
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, {prefix: '<rootDir>/packages/'}),
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|)$': 'jest-mock',
},
}
7 changes: 7 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {configure} from 'enzyme'

const Adapter = require('enzyme-adapter-react-16')

configure({
adapter: new Adapter(),
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lint": "lerna run --no-bail --parallel lint",
"lint:fix": "lerna run --no-bail --parallel lint:fix",
"guide": "lerna run --concurrency=1 guide",
"guide_ci": "lerna run --concurrency=1 guide_ci"
"guide_ci": "lerna run --concurrency=1 guide_ci",
"test": "jest"
},
"husky": {
"hooks": {
Expand Down
25 changes: 25 additions & 0 deletions packages/core/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const {pathsToModuleNameMapper} = require('ts-jest/utils')

const {compilerOptions} = require('../../tsconfig')

module.exports = {
rootDir: '../../',
preset: 'ts-jest',
globals: {
'ts-jest': {
'tsConfig': '<rootDir>/tsconfig.json',
},
},
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
transformIgnorePatterns: ['/node_modules/(?!@qiwi).+ \\ .js $'],
testMatch: ['**/core/**/test/**/*.+(ts|tsx)'],
collectCoverage: true,
snapshotSerializers: ['enzyme-to-json/serializer'],
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, {prefix: '<rootDir>/packages/'}),
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|)$': 'jest-mock',
},
}
10 changes: 9 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"clean": "rm -rf lib",
"build": "mkdir -p lib/es5 && tsc -p tsconfig.build.json && cp -r src/fonts lib/es5/fonts",
"lint": "tslint -p tsconfig.build.json src/**/*.ts{,x}",
"lint:fix": "tslint -p tsconfig.build.json --fix src/**/*.ts{,x}"
"lint:fix": "tslint -p tsconfig.build.json --fix src/**/*.ts{,x}",
"test": "jest"
},
"files": [
"README.md",
Expand All @@ -19,6 +20,8 @@
"@emotion/core": "^10.0.16",
"@emotion/styled": "^10.0.15",
"@types/dom-helpers": "^3.4.1",
"@types/enzyme": "^3.10.5",
"@types/jest": "^25.2.1",
"@types/react": "^16.8.23",
"@types/react-dom": "^16.8.4",
"@types/react-google-recaptcha": "^1.0.0",
Expand All @@ -27,6 +30,10 @@
"dom-helpers": "^3.4.0",
"emotion": "^10.0.14",
"emotion-theming": "^10.0.14",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4",
"jest": "^25.4.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-google-recaptcha": "^1.1.0",
Expand All @@ -35,6 +42,7 @@
"react-text-mask": "^5.4.3",
"react-transition-group": "^4.2.2",
"react-waypoint": "^9.0.2",
"ts-jest": "^25.4.0",
"tslib": "^1.10.0"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
},
"include": [
"src/**/*"
],
"exclude": [
"**/test/**"
]
}
25 changes: 25 additions & 0 deletions packages/desktop/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const {pathsToModuleNameMapper} = require('ts-jest/utils')

const {compilerOptions} = require('../../tsconfig')

module.exports = {
rootDir: '../../',
preset: 'ts-jest',
globals: {
'ts-jest': {
'tsConfig': '<rootDir>/tsconfig.json',
},
},
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
transformIgnorePatterns: ['/node_modules/(?!@qiwi).+ \\ .js $'],
testMatch: ['**/desktop/**/test/**/*.+(ts|tsx)'],
collectCoverage: true,
snapshotSerializers: ['enzyme-to-json/serializer'],
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, {prefix: '<rootDir>/packages/'}),
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|)$': 'jest-mock',
},
}
11 changes: 10 additions & 1 deletion packages/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"lint": "tslint -p tsconfig.build.json src/**/*.ts{,x}",
"lint:fix": "tslint -p tsconfig.build.json --fix src/**/*.ts{,x}",
"guide": "gh-pages -d styleguide/lib -e desktop -m \"update desktop style guide v$npm_package_version\"",
"guide_ci": "gh-pages -d styleguide/lib -e desktop -m \"update desktop style guide v$npm_package_version\" -r \"https://[email protected]/qiwi/pijma.git\""
"guide_ci": "gh-pages -d styleguide/lib -e desktop -m \"update desktop style guide v$npm_package_version\" -r \"https://[email protected]/qiwi/pijma.git\"",
"test": "jest"
},
"files": [
"README.md",
Expand All @@ -22,6 +23,9 @@
"@emotion/core": "^10.0.16",
"@emotion/styled": "^10.0.15",
"@qiwi/pijma-core": "^1.x.x",
"@types/enzyme": "^3.10.5",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/jest": "^25.2.1",
"@types/markdown-to-jsx": "^6.9.0",
"@types/react": "^16.8.23",
"@types/react-dom": "^16.8.4",
Expand All @@ -30,12 +34,17 @@
"@types/react-transition-group": "^4.2.2",
"emotion": "^10.0.14",
"emotion-theming": "^10.0.14",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4",
"jest": "^25.4.0",
Irinaa133 marked this conversation as resolved.
Show resolved Hide resolved
"markdown-to-jsx": "^6.10.3",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-overlays": "^1.2.0",
"react-text-mask": "^5.4.3",
"react-transition-group": "^4.2.2",
"ts-jest": "^25.4.0",
"tslib": "^1.10.0"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = {
],
ignore: [
'**/*/index.{js,jsx,ts,tsx}',
'**/test/**',
],
skipComponentsWithoutExample: true,
getComponentPathLine(file) {
Expand Down
3 changes: 3 additions & 0 deletions packages/desktop/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
},
"include": [
"src/**/*"
],
"exclude": [
"**/test/**"
]
Irinaa133 marked this conversation as resolved.
Show resolved Hide resolved
}
25 changes: 25 additions & 0 deletions packages/mobile/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const {pathsToModuleNameMapper} = require('ts-jest/utils')

const {compilerOptions} = require('../../tsconfig')

module.exports = {
rootDir: '../../',
preset: 'ts-jest',
globals: {
'ts-jest': {
'tsConfig': '<rootDir>/tsconfig.json',
},
},
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
transformIgnorePatterns: ['/node_modules/(?!@qiwi).+ \\ .js $'],
testMatch: ['**/mobile/**/test/**/*.+(ts|tsx)'],
collectCoverage: true,
snapshotSerializers: ['enzyme-to-json/serializer'],
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, {prefix: '<rootDir>/packages/'}),
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|)$': 'jest-mock',
},
}
10 changes: 9 additions & 1 deletion packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"lint": "tslint -p tsconfig.build.json src/**/*.ts{,x}",
"lint:fix": "tslint -p tsconfig.build.json --fix src/**/*.ts{,x}",
"guide": "gh-pages -d styleguide/lib -e mobile -m \"update mobile style guide v$npm_package_version\"",
"guide_ci": "gh-pages -d styleguide/lib -e mobile -m \"update mobile style guide v$npm_package_version\" -r \"https://[email protected]/qiwi/pijma.git\""
"guide_ci": "gh-pages -d styleguide/lib -e mobile -m \"update mobile style guide v$npm_package_version\" -r \"https://[email protected]/qiwi/pijma.git\"",
"test": "jest"
},
"files": [
"README.md",
Expand All @@ -22,6 +23,8 @@
"@emotion/core": "^10.0.16",
"@emotion/styled": "^10.0.15",
"@qiwi/pijma-core": "^1.x.x",
"@types/enzyme": "^3.10.5",
"@types/jest": "^25.2.1",
"@types/markdown-to-jsx": "^6.9.0",
"@types/react": "^16.8.23",
"@types/react-dom": "^16.8.4",
Expand All @@ -30,12 +33,17 @@
"@types/react-transition-group": "^4.2.2",
"emotion": "^10.0.14",
"emotion-theming": "^10.0.14",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4",
"jest": "^25.4.0",
"markdown-to-jsx": "^6.10.3",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-overlays": "^1.2.0",
"react-text-mask": "^5.4.3",
"react-transition-group": "^4.2.2",
"ts-jest": "^25.4.0",
"tslib": "^1.10.0"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = {
],
ignore: [
'**/*/index.{js,jsx,ts,tsx}',
'**/test/**',
],
skipComponentsWithoutExample: true,
getComponentPathLine(componentPath) {
Expand Down
3 changes: 3 additions & 0 deletions packages/mobile/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
},
"include": [
"src/**/*"
],
"exclude": [
"**/test/**"
]
}
8 changes: 8 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"extends": "./tsconfig.base.json",

"exclude": ["node_modules"],

"compilerOptions": {
"jsx": "react",
Copy link
Collaborator

Choose a reason for hiding this comment

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

доп параметры на билд не влияют? все норм пашет потом?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

все работает

"lib": ["dom", "esnext"],
"module": "esnext",
"esModuleInterop": true,

"baseUrl": "./packages",
"paths": {
"@qiwi/pijma-core": [
Expand Down
Loading