Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@gojob/wait-for-assertion
Advanced tools
A wrapper for asynchronous testing assertions.
yarn add @gojob/wait-for-assertion
# or
npm install @gojob/wait-for-assertion
By "asynchronous assertions", we means Assertions that must be executed with a delay. The typical use case that we want to avoid is the following:
await myFunctionWithAsyncSideEffects();
await new Promise(resolve => setTimeout(resolve, 1000)); // ❌ 🤢 🤮
expect(mySideEffectExists()).toBe(true);
waitForAssertion
will run the given function (containing assertions) until it stops throwing exceptions (which means that it "passed"), or will throw a Timeout error.
waitForAssertion
accepts up to three parameters:
function waitForAssertion(
assertion: () => any,
timeoutDelay: number = 1000,
intervalDelay: number = 100
);
assertion
: Closure containing asynchronous assertions to be made.timeoutDelay
: [1000ms] How long should the assertion be repeated until it passes (or times out).intervalDelay
: [100ms] How often should the assertion be repeated during timeoutDelay
.import { waitForAssertion } from '@gojob/wait-for-assertion';
// [...]
it('should asynchronously update the value in Elasticsearch', async () => {
await request(server)
.put(endpointURL)
.send(input)
.expect(HttpStatus.NO_CONTENT);
// the document is not immediatly available in Elasticsearch: wait
await waitForAssertion(async () => {
const { document } = await elasticsearchService.get(UserIndex, userId);
return expect(document.firstName).toBe(updatedUser.firstName);
});
});
Developed by VinceOPS at Gojob.
Initial blog story: 🇫🇷 article
FAQs
Wait for asynchronous testing assertions
The npm package @gojob/wait-for-assertion receives a total of 1 weekly downloads. As such, @gojob/wait-for-assertion popularity was classified as not popular.
We found that @gojob/wait-for-assertion demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.