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 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
/node_modules
/packages/*/node_modules
/packages/*/lib
/packages/*/buildcache
/coverage
Copy link
Collaborator

Choose a reason for hiding this comment

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

таки может /packages/*/coverage?

Copy link
Member

Choose a reason for hiding this comment

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

Не-а. Там и корне будет coverage.

.DS_Store
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ install:

script:
- yarn build
- yarn test

deploy:
provider: script
skip_cleanup: true
script:
- yarn lerna exec --concurrency 1 "npx --no-install semantic-release -e semantic-release-monorepo" && node -e "require('semantic-release-monorepo-hooks').hookAfterAll()"
- yarn lerna exec --concurrency 1 "npx --no-install semantic-release -e semantic-release-monorepo" && node -e "require('semantic-release-monorepo-hooks').hookAfterAll()"
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": "lerna run test --stream"
},
"husky": {
"hooks": {
Expand Down
30 changes: 30 additions & 0 deletions packages/core/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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,
collectCoverageFrom: [
'**/core/src/*/*.ts{,x}',
],
coverageDirectory: '<rootDir>/coverage/core',
coveragePathIgnorePatterns: ['node_modules', 'index.ts'],
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',
},
}
23 changes: 16 additions & 7 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{
"name": "@qiwi/pijma-core",
"version": "1.111.0",
"license": "MIT",
"main": "lib/es5/index.js",
"types": "lib/es5/index.d.ts",
"license": "MIT",
"scripts": {
"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}"
},
"files": [
"README.md",
"CHANGELOG.md",
"lib"
],
"scripts": {
"prebuild": "rimraf buildcache",
"build": "mkdir -p lib/es5 && tsc -p tsconfig.build.json && cp -r src/fonts lib/es5/fonts",
"clean": "rm -rf lib",
"lint": "tslint -p tsconfig.build.json src/**/*.ts{,x}",
"lint:fix": "tslint -p tsconfig.build.json --fix src/**/*.ts{,x}",
"test": "jest"
},
"dependencies": {
"@emotion/core": "^10.0.16",
"@emotion/styled": "^10.0.15",
Expand All @@ -38,7 +40,14 @@
"tslib": "^1.10.0"
},
"devDependencies": {
"@types/enzyme": "^3.10.5",
"@types/jest": "^25.2.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4",
"husky": "3.0.3",
"jest": "^25.4.0",
"ts-jest": "^25.4.0",
"tslint": "5.18.0",
"tslint-config-qiwi": "1.1.1",
"typescript": "3.5.3"
Expand Down
5 changes: 5 additions & 0 deletions packages/core/test/Jest.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('test jest', () => {
it('jest runner', () => {
expect(true).toBeTruthy()
})
})
7 changes: 6 additions & 1 deletion packages/core/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
"compilerOptions": {
"rootDir": "src",
"outDir": "lib/es5",
"baseUrl": "src"
"baseUrl": "src",
"incremental": true,
"tsBuildInfoFile": "./buildcache/.tsbuildinfo"
},
"include": [
"src/**/*"
],
"exclude": [
"**/test/**"
]
}
30 changes: 30 additions & 0 deletions packages/desktop/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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,
collectCoverageFrom: [
'**/desktop/src/*/*.ts{,x}',
],
coverageDirectory: '<rootDir>/coverage/desktop',
coveragePathIgnorePatterns: ['node_modules', 'index.ts'],
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',
},
}
29 changes: 19 additions & 10 deletions packages/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
{
"name": "@qiwi/pijma-desktop",
"version": "1.111.0",
"license": "MIT",
"main": "lib/es5/index.js",
"types": "lib/es5/index.d.ts",
"license": "MIT",
"scripts": {
"clean": "rm -rf lib styleguide/lib",
"build": "mkdir -p lib/es5 && tsc -p tsconfig.build.json && styleguidist build",
"watch": "styleguidist server",
"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\""
},
"files": [
"README.md",
"CHANGELOG.md",
"lib"
],
"scripts": {
"prebuild": "rimraf buildcache",
"build": "mkdir -p lib/es5 && tsc -p tsconfig.build.json && styleguidist build",
"clean": "rm -rf lib styleguide/lib",
"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\"",
"lint": "tslint -p tsconfig.build.json src/**/*.ts{,x}",
"lint:fix": "tslint -p tsconfig.build.json --fix src/**/*.ts{,x}",
"test": "jest",
"watch": "styleguidist server"
},
"dependencies": {
"@emotion/core": "^10.0.16",
"@emotion/styled": "^10.0.15",
Expand All @@ -39,12 +41,19 @@
"tslib": "^1.10.0"
},
"devDependencies": {
"@types/enzyme": "^3.10.5",
"@types/jest": "^25.2.1",
"@types/webpack-env": "1.14.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4",
"file-loader": "4.2.0",
"gh-pages": "2.1.1",
"husky": "3.0.3",
"jest": "^25.4.0",
"react-docgen-typescript": "1.12.5",
"react-styleguidist": "9.1.14",
"ts-jest": "^25.4.0",
"ts-loader": "6.0.4",
"tslint": "5.18.0",
"tslint-config-qiwi": "1.1.1",
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
5 changes: 5 additions & 0 deletions packages/desktop/test/Jest.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('test jest', () => {
it('jest runner', () => {
expect(true).toBeTruthy()
})
})
7 changes: 6 additions & 1 deletion packages/desktop/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
"compilerOptions": {
"rootDir": "src",
"outDir": "lib/es5",
"baseUrl": "src"
"baseUrl": "src",
"incremental": true,
"tsBuildInfoFile": "./buildcache/.tsbuildinfo"
},
"include": [
"src/**/*"
],
"exclude": [
"**/test/**"
]
Irinaa133 marked this conversation as resolved.
Show resolved Hide resolved
}
30 changes: 30 additions & 0 deletions packages/mobile/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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,
collectCoverageFrom: [
'**/mobile/src/*/*.ts{,x}',
],
coverageDirectory: '<rootDir>/coverage/mobile',
coveragePathIgnorePatterns: ['node_modules', 'index.ts'],
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',
},
}
29 changes: 19 additions & 10 deletions packages/mobile/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
{
"name": "@qiwi/pijma-mobile",
"version": "1.111.0",
"license": "MIT",
"main": "lib/es5/index.js",
"types": "lib/es5/index.d.ts",
"license": "MIT",
"scripts": {
"clean": "rm -rf lib styleguide/lib",
"build": "mkdir -p lib/es5 && tsc -p tsconfig.build.json && styleguidist build",
"watch": "styleguidist server",
"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\""
},
"files": [
"README.md",
"CHANGELOG.md",
"lib"
],
"scripts": {
"prebuild": "rimraf buildcache",
"build": "mkdir -p lib/es5 && tsc -p tsconfig.build.json && styleguidist build",
"clean": "rm -rf lib styleguide/lib",
"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\"",
"lint": "tslint -p tsconfig.build.json src/**/*.ts{,x}",
"lint:fix": "tslint -p tsconfig.build.json --fix src/**/*.ts{,x}",
"test": "jest",
"watch": "styleguidist server"
},
"dependencies": {
"@emotion/core": "^10.0.16",
"@emotion/styled": "^10.0.15",
Expand All @@ -39,12 +41,19 @@
"tslib": "^1.10.0"
},
"devDependencies": {
"@types/enzyme": "^3.10.5",
Irinaa133 marked this conversation as resolved.
Show resolved Hide resolved
"@types/jest": "^25.2.1",
"@types/webpack-env": "1.14.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4",
"file-loader": "4.2.0",
"gh-pages": "2.1.1",
"husky": "3.0.3",
"jest": "^25.4.0",
"react-docgen-typescript": "1.12.5",
"react-styleguidist": "9.1.14",
"ts-jest": "^25.4.0",
"ts-loader": "6.0.4",
"tslint": "5.18.0",
"tslint-config-qiwi": "1.1.1",
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
5 changes: 5 additions & 0 deletions packages/mobile/test/Jest.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('test jest', () => {
it('jest runner', () => {
expect(true).toBeTruthy()
})
})
7 changes: 6 additions & 1 deletion packages/mobile/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
"compilerOptions": {
"rootDir": "src",
"outDir": "lib/es5",
"baseUrl": "src"
"baseUrl": "src",
"incremental": true,
"tsBuildInfoFile": "./buildcache/.tsbuildinfo"
},
"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