-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from lifeomic/customMatchers
Exposing matchers at the top level
- Loading branch information
Showing
11 changed files
with
2,170 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
{ | ||
"extends": [ | ||
"@lifeomic/standards/javascript" | ||
"@lifeomic/standards" | ||
], | ||
"env": { | ||
"node": true | ||
"node": true, | ||
"jest": true, | ||
"jest/globals": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
name: PR Branch Build and Test | ||
name: PR Build and Test | ||
|
||
on: pull_request | ||
on: | ||
pull_request | ||
|
||
jobs: | ||
build: | ||
test: | ||
runs-on: ubuntu-latest | ||
name: Node.JS ${{ matrix.node-version }} | ||
strategy: | ||
matrix: | ||
node-version: [12.x, 14.x, 16.x] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Install | ||
run: yarn install | ||
- name: Test | ||
run: yarn test | ||
preRelease: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
- name: Lint | ||
run: | | ||
yarn | ||
yarn lint | ||
registry-url: https://registry.npmjs.org | ||
- name: Install | ||
run: yarn install --frozen-lockfile | ||
- name: Version | ||
env: | ||
PRE_ID: pr-${{ github.event.number }}-${{ github.run_id }} | ||
run: npm version prepatch --git-tag-version=false --preid="${PRE_ID}-$(date '+%s')" | ||
- name: PrePublish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.LIFEOMIC_NPM_TOKEN}} | ||
PR_TAG: pr-${{ github.event.number }} | ||
run: npm publish --tag "${PR_TAG}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Matchers } from 'expect/build/types'; | ||
import matchers from 'expect/build/matchers'; | ||
|
||
const invalidKeys = ['resolves', 'rejects', 'not'] as const; | ||
|
||
export type InvalidKeys = typeof invalidKeys[number]; | ||
export type ValidKeys = keyof Omit<Matchers<any>, InvalidKeys> | ||
|
||
type RootMatchers = { | ||
[key in ValidKeys]: Matchers<any>[key]; | ||
} | ||
|
||
const rootMatchers = {} as RootMatchers; | ||
|
||
Object.keys(matchers) | ||
.filter((name): name is ValidKeys => !invalidKeys.includes(name as InvalidKeys)) | ||
.forEach((name) => { | ||
const matcher = matchers[name]; | ||
rootMatchers[name] = matcher.bind({}); | ||
}); | ||
|
||
expect.extend(rootMatchers); | ||
|
||
declare global { | ||
namespace jest { | ||
interface Expect extends RootMatchers {} | ||
interface InverseAsymmetricMatchers extends RootMatchers {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
preset: './jest-preset.js', | ||
maxWorkers: 1, | ||
collectCoverage: true, | ||
coverageThreshold: { | ||
global: { | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
statements: 100, | ||
}, | ||
}, | ||
coveragePathIgnorePatterns: ['<rootDir>/test/', '/node_modules/'], | ||
restoreMocks: true, | ||
resetMocks: true, | ||
testMatch: ['<rootDir>/test/**/*.test.ts'], | ||
verbose: true, | ||
setupFilesAfterEnv: ['<rootDir>/test/setup.ts'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
test('has exposed some desired methods', () => { | ||
expect({ | ||
numberVal: .31, | ||
otherNum: .3, | ||
}).toEqual({ | ||
numberVal: expect.toBeCloseTo(0.3, 1), | ||
otherNum: expect.not.toBeCloseTo(0.2), | ||
}); | ||
expect(.31).toBeCloseTo(0.3, 1); | ||
expect(.3).not.toBeCloseTo(0.2); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import '../index'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": false | ||
}, | ||
"include": [ | ||
"./index.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "@lifeomic/typescript-config", | ||
"compilerOptions": { | ||
"resolveJsonModule": true, | ||
"module": "CommonJS", | ||
"declaration": true, | ||
"noEmit": true | ||
}, | ||
"include": [ | ||
"./index.ts", | ||
"test/**/*.ts" | ||
] | ||
} |
Oops, something went wrong.