@universal-packages/background-jobs-jest
Advanced tools
Comparing version 1.0.7 to 1.0.8
22
index.js
@@ -19,3 +19,3 @@ "use strict"; | ||
message: () => `expected ${this.utils.printReceived(job['name'])} not to have been enqueued, bit it was`, | ||
pass: true | ||
pass | ||
}; | ||
@@ -27,6 +27,6 @@ } | ||
if (calls.length === 0) { | ||
return `expected ${this.utils.printReceived(job['name'])} to have been enqueued but no enqueues were found`; | ||
return `expected ${this.utils.printReceived(job['name'])} to have been enqueued but no enqueues were made`; | ||
} | ||
else { | ||
return `expected ${this.utils.printReceived(job['name'])} to have been enqueued but enqueues were: ${calls | ||
return `expected ${this.utils.printReceived(job['name'])} to have been enqueued but it was not\n\nEnqueues were: ${calls | ||
.map((call) => this.utils.printExpected(call[0])) | ||
@@ -36,3 +36,3 @@ .join(', ')}`; | ||
}, | ||
pass: false | ||
pass | ||
}; | ||
@@ -50,4 +50,4 @@ } | ||
return { | ||
message: () => `expected ${this.utils.printReceived(job['name'])} not to have been enqueued with ${this.utils.printReceived(payload)}, bit it was`, | ||
pass: true | ||
message: () => `expected ${this.utils.printReceived(job['name'])} not to have been enqueued with the given payload, bit it was`, | ||
pass | ||
}; | ||
@@ -59,3 +59,3 @@ } | ||
if (jobCalls.length === 0) { | ||
return `expected ${this.utils.printReceived(job['name'])} to have been enqueued with ${this.utils.printReceived(payload)} but the it was not enqueued any times`; | ||
return `expected ${this.utils.printReceived(job['name'])} to have been enqueued, but it was not enqueued at all`; | ||
} | ||
@@ -66,11 +66,9 @@ else { | ||
const [_jobName, _queue, jobPayload] = call; | ||
if (typeof jobPayload === 'object' && typeof payload === 'object') | ||
return this.utils.printExpected(this.utils.diff(payload, jobPayload)); | ||
return this.utils.printExpected(jobPayload); | ||
return this.utils.diff(payload, jobPayload); | ||
}) | ||
.join('\n\n'); | ||
return `expected ${this.utils.printReceived(job['name'])} to have been enqueued with ${this.utils.printReceived(payload)} but job was enqueued with:\n${jobCallsToPrint}`; | ||
return `expected ${this.utils.printReceived(job['name'])} to have been enqueued with the given payload but it was not\n\nEnqueue payloads were:\n${jobCallsToPrint}`; | ||
} | ||
}, | ||
pass: false | ||
pass | ||
}; | ||
@@ -77,0 +75,0 @@ } |
{ | ||
"name": "@universal-packages/background-jobs-jest", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Jest matchers for Background Jobs", | ||
@@ -22,29 +22,16 @@ "author": "David De Anda <david@universal-packages.com> (https://github.com/universal-packages)", | ||
"devDependencies": { | ||
"@trivago/prettier-plugin-sort-imports": "^4.1.1", | ||
"@types/cron": "^2.0.0", | ||
"@types/jest": "^29.5.4", | ||
"@types/node": "^17.0.39", | ||
"@types/uuid": "^8.3.4", | ||
"@universal-packages/maintenance": "^1.1.2", | ||
"jest": "^29.6.4", | ||
"jest-circus": "^29.6.4", | ||
"prettier": "^2.8.7", | ||
"@trivago/prettier-plugin-sort-imports": "^4.2.0", | ||
"@types/jest": "^29.5.5", | ||
"@types/node": "^18.11.9", | ||
"@universal-packages/maintenance": "^1.2.2", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.0.3", | ||
"strip-ansi": "^6.0.0", | ||
"ts-jest": "^29.1.1", | ||
"typescript": "^4.7.3" | ||
"typescript": "^5.2.2" | ||
}, | ||
"jest": { | ||
"testRunner": "jest-circus/runner", | ||
"transform": { | ||
"^.+\\.(ts|tsx)$": "ts-jest" | ||
}, | ||
"testRegex": "(/tests/.*\\.test\\.ts?)$", | ||
"preset": "ts-jest", | ||
"collectCoverageFrom": [ | ||
"src/**/*.ts" | ||
], | ||
"setupFilesAfterEnv": [ | ||
"<rootDir>/tests/setupTests.ts" | ||
], | ||
"watchPathIgnorePatterns": [ | ||
"<rootDir>/tmp" | ||
] | ||
@@ -51,0 +38,0 @@ }, |
@@ -19,6 +19,8 @@ # Background Jobs Jest | ||
Import this library in your `<setupTests>` file. | ||
Add the following to your `jest.config.js` or where you configure Jest: | ||
```js | ||
import '@universal-packages/background-jobs-jest' | ||
module.exports = { | ||
setupFilesAfterEnv: ['@universal-packages/background-jobs-jest'] | ||
} | ||
``` | ||
@@ -54,2 +56,8 @@ | ||
In order for typescript to see the global types you need to reference the types somewhere in your project, normally `./src/globals.d.ts`. | ||
```ts | ||
/// <reference types="@universal-packages/background-jobs-jest" /> | ||
``` | ||
This library is developed in TypeScript and shipped fully typed. | ||
@@ -56,0 +64,0 @@ |
Sorry, the diff of this file is not supported yet
9
73
10336
86