Skip to content

Commit

Permalink
Merge pull request #61 from Roaders/main
Browse files Browse the repository at this point in the history
Update to handle jest 27
  • Loading branch information
Roaders authored May 18, 2022
2 parents 8325cfe + 44ebefe commit 36d01e2
Show file tree
Hide file tree
Showing 6 changed files with 17,173 additions and 6,551 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [10.x, 12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v2
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Create Release
on:
push:
branches:
- main

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '16.x'

- name: Install node modules and verify build
run: npm ci && npm run build-release

- name: Release
uses: justincy/[email protected]
id: release

- name: Print release output
if: ${{ steps.release.outputs.released == 'true' }}
run: echo Release ID ${{ steps.release.outputs.release_id }}

- name: Publish
if: steps.release.outputs.released == 'true'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
25 changes: 0 additions & 25 deletions .github/workflows/release.yml

This file was deleted.

24 changes: 24 additions & 0 deletions main/mock/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,37 @@ export const matchers = {
wasCalledAtLeastOnce,
};

/* istanbul ignore next */
export function addMatchers() {
// jasmine.addMatchers must be called in a before function so this will sometimes throw an error
try {
jasmine.addMatchers(matchers);
} catch (e) {
// NOP
}

try {
(expect as unknown as jest.Expect).extend({
wasCalled: mapToJestCustomMatcher(wasCalled()),
wasCalledOnce: mapToJestCustomMatcher(wasCalledOnce()),
wasNotCalled: mapToJestCustomMatcher(wasNotCalled()),
wasCalledAtLeastOnce: mapToJestCustomMatcher(wasCalledAtLeastOnce()),
});
} catch (e) {
// NOP
}
}

/* istanbul ignore next */
function mapToJestCustomMatcher(matcher: ICustomMatcher): jest.CustomMatcher {
return (context: IFunctionVerifier<any, any>, received: any, ...actual: any[]) => {
const result = matcher.compare(context, received, ...actual);

return {
pass: result.pass,
message: typeof result.message === 'function' ? result.message : () => result.message || 'failed',
};
};
}

function wasCalled(): ICustomMatcher {
Expand Down
Loading

0 comments on commit 36d01e2

Please sign in to comment.