Skip to content

Commit

Permalink
chore: nx testing integration
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemhiller authored Aug 9, 2022
1 parent 9984674 commit f12c0ae
Show file tree
Hide file tree
Showing 259 changed files with 5,051 additions and 535 deletions.
6 changes: 2 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,20 @@ jobs:

tests:
<<: *default_env
parallelism: 7
resource_class: large
steps:
- checkout
- *restore_node_modules
- *restore_nx_cache
- *build_all_packages
- *save_nx_cache
- run:
name: Run test suite
command: |
export TESTFILES=$(yarn --silent test --listTests | xargs realpath -q --relative-to=$PWD "$1" | sort | circleci tests split --split-by=timings)
yarn test --ci --runInBand --runTestsByPath ${TESTFILES} --coverage --reporters="default" --reporters="jest-junit"
yarn test --parallel=4 --ci --coverage -- --runInBand
environment:
JEST_JUNIT_OUTPUT_DIR: /tmp/test-results/junit
JEST_JUNIT_ADD_FILE_ATTRIBUTE: 'true'
- *save_nx_cache
- store_test_results:
path: /tmp/test-results
- store_artifacts:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ tmp
dist/storybook
dist/docs

# NX
dist/out-tsc
*.tsbuildinfo

packages/gamut-styles/demo-styles

# For vim users
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"storyExplorer.storiesGlobs": "packages/styleguide/stories/**/*.stories.mdx"
"storyExplorer.storiesGlobs": "packages/styleguide/stories/**/*.stories.mdx",
"jest.jestCommandLine": "node_modules/.bin/jest"
}
2 changes: 2 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
registry "https://registry.npmjs.org/"
workspaces-experimental true

--ignore-workspace-root-check true
14 changes: 1 addition & 13 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
module.exports = {
presets: ['codecademy', '@babel/preset-typescript'],
plugins: [
'macros',
[
'@emotion',
{
sourceMap: true,
autoLabel: 'always',
labelFormat: '[local]',
},
],
],
ignore: [],
babelrcRoots: ['*'],
};
17 changes: 17 additions & 0 deletions babel.defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
let ignorePatterns = ['./**/*.d.ts'];

if (process.env.NODE_ENV !== 'test') {
ignorePatterns = [
...ignorePatterns,
'**/*.(test|spec).ts{,.snap}',
'**/*.(test|spec).tsx',
'**/tests',
'**/__tests__',
'**/__mocks__',
'**/__fixtures',
];
}

module.exports = {
ignore: ignorePatterns,
};
72 changes: 0 additions & 72 deletions jest.config.base.js

This file was deleted.

23 changes: 23 additions & 0 deletions jest.config.base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const baseConfig = (packageName: string, overrides: Object) => ({
displayName: packageName,
preset: '../../jest.preset.js',
clearMocks: true,
verbose: true,
coverageDirectory: process.env.CI
? `/tmp/test-results/jest/${packageName}`
: `../../coverage/packages/${packageName}`,
reporters: process.env.CI
? ['default', ['jest-junit', { outputName: `${packageName}-report.xml` }]]
: ['default'],
coverageReporters: ['json', 'text', 'clover'],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|md)$':
'<rootDir>/../../script/jest/fileMock',
'\\.(css|scss)$': '<rootDir>/../../script/jest/styleMock',
},
transformIgnorePatterns: ['./disable-transform-ignoring-for-node_modules'],
testPathIgnorePatterns: ['node_modules', 'dist'],
...overrides,
});

export default baseConfig;
3 changes: 0 additions & 3 deletions jest.config.js

This file was deleted.

5 changes: 5 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getJestProjects } from '@nrwl/jest';

export default {
projects: getJestProjects(),
};
5 changes: 5 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const nxPreset = require('@nrwl/jest/preset').default;

module.exports = {
...nxPreset,
};
10 changes: 9 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,17 @@
}
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*"],
"prod": [
"!{projectRoot}/**/*.(test|spec).ts{,.snap}",
"!{projectRoot}/**/__tests__/**/*"
]
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"]
"dependsOn": ["^build"],
"inputs": ["prod", "^prod"]
}
},
"cli": {
Expand Down
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"yarn": "^1.21.1"
},
"scripts": {
"test": "jest",
"test": "nx run-many --target=test --all",
"lint": "eslint --ignore-path .eslintignore \"./**/*.{mdx,js,ts,tsx,json}\" --max-warnings 0",
"lint:fix": "yarn lint --fix",
"prettier": "prettier --ignore-path .prettierignore \"./**/*.{mdx,js,ts,tsx,json,css,scss}\"",
Expand Down Expand Up @@ -51,20 +51,21 @@
"**/storybook-*/**"
]
},
"devDependencies": {
"@babel/cli": "7.18.10",
"@babel/core": "7.18.10",
"@babel/preset-typescript": "^7.18.6",
"dependencies": {
"@babel/cli": "7.17.10",
"@babel/core": "7.13.10",
"@babel/preset-typescript": "^7.13.0",
"@codecademy/eslint-config": "8.0.0",
"@codecademy/prettier-config": "^0.2.0",
"@codecademy/tsconfig": "^0.2.0",
"@emotion/babel-plugin": "^11.3.0",
"@emotion/jest": "^11.3.0",
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"@nrwl/cli": "^14.4.3",
"@nrwl/cli": "^14.5.2",
"@nrwl/nx-cloud": "^14.3.0",
"@nrwl/workspace": "^14.4.3",
"@nrwl/jest": "^14.5.2",
"@nrwl/react": "^14.5.2",
"@svgr/cli": "5.5.0",
"@testing-library/dom": "^8.11.1",
"@testing-library/jest-dom": "^5.16.1",
Expand All @@ -90,6 +91,7 @@
"conventional-changelog-cli": "^2.0.34",
"conventional-changelog-conventionalcommits": "^4.3.0",
"core-js": "3.7.0",
"cpy-cli": "^4.1.0",
"enzyme": "^3.11.0",
"enzyme-to-json": "3.3.5",
"eslint": "^8.11.0",
Expand All @@ -113,6 +115,9 @@
"react-helmet": "6.1.0",
"react-test-renderer": "^17.0.2",
"svgo": "^1.3.2",
"ts-jest": "^28.0.7",
"ts-node": "^10.9.1",
"tslib": "2.4.0",
"typescript": "4.4.2"
},
"resolutions": {
Expand Down
6 changes: 0 additions & 6 deletions packages/eslint-plugin-gamut/.npmignore

This file was deleted.

5 changes: 0 additions & 5 deletions packages/eslint-plugin-gamut/jest.config.js

This file was deleted.

7 changes: 7 additions & 0 deletions packages/eslint-plugin-gamut/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import base from '../../jest.config.base';

export default base('eslint-plugin-gamut', {
testEnvironment: 'node',
setupFiles: [],
setupFilesAfterEnv: [],
});
3 changes: 3 additions & 0 deletions packages/eslint-plugin-gamut/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"styles",
"gamut-styles"
],
"files": [
"dist"
],
"name": "eslint-plugin-gamut",
"version": "2.0.1",
"license": "MIT",
Expand Down
12 changes: 10 additions & 2 deletions packages/eslint-plugin-gamut/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/eslint-plugin-gamut/src",
"projectType": "library",
"targets": {
Expand All @@ -9,9 +9,17 @@
"options": {
"cwd": "packages/eslint-plugin-gamut",
"outputPath": "./dist",
"commands": ["rm -rf ./dist", "tsc"],
"commands": ["rm -rf ./dist", "tsc -p tsconfig.lib.json"],
"parallel": false
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/packages/eslint-plugin-gamut"],
"options": {
"jestConfig": "packages/eslint-plugin-gamut/jest.config.ts",
"passWithNoTests": true
}
}
},
"tags": []
Expand Down
17 changes: 11 additions & 6 deletions packages/eslint-plugin-gamut/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../../tsconfig.json",
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"compilerOptions": {
"module": "CommonJS",
"outDir": "./dist"
}
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
21 changes: 21 additions & 0 deletions packages/eslint-plugin-gamut/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": true,
"module": "CommonJS",
"outDir": "./dist",
"rootDir": "./src"
},
"exclude": [
"jest.config.ts",
"**/*.spec.ts",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.test.tsx",
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx"
],
"include": ["./src/**/*.ts", "./src/**/*.tsx"]
}
21 changes: 21 additions & 0 deletions packages/eslint-plugin-gamut/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"module": "commonjs",
"outDir": "./dist",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"**/*.test.ts",
"**/*.spec.ts",
"**/*.test.tsx",
"**/*.spec.tsx",
"**/*.test.js",
"**/*.spec.js",
"**/*.test.jsx",
"**/*.spec.jsx",
"**/*.d.ts"
]
}
2 changes: 0 additions & 2 deletions packages/gamut-icons/.npmignore

This file was deleted.

Loading

0 comments on commit f12c0ae

Please sign in to comment.