Skip to content

Commit

Permalink
test(): Update jest to use projects
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-martin committed May 21, 2020
1 parent 8926e12 commit 23911ef
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 50 deletions.
40 changes: 5 additions & 35 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,7 @@ on:
env:
CI: true
jobs:
unit:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Restore Dependencies
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{matrix.node-version}}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{matrix.node-version}}-
- run: npm ci
- run: npm run bootstrap
- run: npm test
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-unit-${{ matrix.node-version }}
parallel: true

e2e:
test:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -61,19 +33,17 @@ jobs:
restore-keys: |
${{ runner.os }}-node-${{matrix.node-version}}-
- run: npm ci
- run: npm run bootstrap -- --ignore-scripts
- run: npm run build
- run: npx lerna run migrate:up
- run: npm run test:e2e
- run: npm run bootstrap
- run: npm test
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-e2e-${{ matrix.node-version }}
flag-name: run-${{ matrix.node-version }}
parallel: true

finish:
needs: [unit, e2e]
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
Expand Down
2 changes: 1 addition & 1 deletion .huskyrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"skipCI": false,
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "npm test"
"pre-commit": "npm run lint"
}
}
2 changes: 1 addition & 1 deletion .run/jest.config.js.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<node-options value="" />
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
<working-dir value="$PROJECT_DIR$" />
<jest-options value="--coverage" />
<jest-options value="--runInBand --coverage" />
<envs />
<scope-kind value="ALL" />
<method v="2" />
Expand Down
13 changes: 13 additions & 0 deletions .run/jest.unit.config.js.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="jest.unit.config.js" type="JavaScriptTestRunnerJest" nameIsGenerated="true">
<config-file value="$PROJECT_DIR$/jest.unit.config.js" />
<node-interpreter value="project" />
<node-options value="" />
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
<working-dir value="$PROJECT_DIR$" />
<jest-options value="--coverage" />
<envs />
<scope-kind value="ALL" />
<method v="2" />
</configuration>
</component>
9 changes: 1 addition & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
// jest.config.js
module.exports = {
// [...]
// Replace `ts-jest` with the preset you want to use
// from the above list
preset: 'ts-jest',
projects: ['./jest.unit.config.js', './jest.e2e.config.js'],
collectCoverageFrom: ['packages/**/*.ts', '!**/__tests__/**', '!**/dist/**', '!**/node_modules/**'],
testMatch: ['**/__tests__/**/*.spec.ts'],
moduleNameMapper: {
'^@nestjs-query/(.*)$': '<rootDir>/packages/$1/src',
},
};
4 changes: 1 addition & 3 deletions jest.e2e.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// jest.config.js
module.exports = {
// [...]
// Replace `ts-jest` with the preset you want to use
// from the above list
displayName: 'E2E',
preset: 'ts-jest',
testMatch: ['**/e2e/**/*.spec.ts'],
collectCoverageFrom: ['packages/**/*.ts', '!**/__tests__/**', '!**/dist/**', '!**/node_modules/**'],
Expand Down
10 changes: 10 additions & 0 deletions jest.unit.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// jest.config.js
module.exports = {
displayName: 'Unit',
preset: 'ts-jest',
collectCoverageFrom: ['packages/**/*.ts', '!**/__tests__/**', '!**/dist/**', '!**/node_modules/**'],
testMatch: ['**/__tests__/**/*.spec.ts'],
moduleNameMapper: {
'^@nestjs-query/(.*)$': '<rootDir>/packages/$1/src',
},
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"test:e2e": "npm run jest:e2e",
"lint": "eslint --ext=.ts .",
"lint:fix": "eslint --fix --ext=.ts .",
"jest": "jest --coverage",
"jest:e2e": "jest --runInBand --config=./jest.e2e.config.js --coverage",
"jest": "jest --runInBand --coverage",
"jest:e2e": "jest --runInBand --coverage --config=./jest.e2e.config.js",
"jest:unit": "jest --coverage --config=./jest.unit.config.js",
"coverage": "cat ./coverage/lcov.info | coveralls"
},
"devDependencies": {
Expand Down

0 comments on commit 23911ef

Please sign in to comment.