
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@oskarer/enzyme-wait
Advanced tools
Wait for an async element to appear when performing integration tests with enzyme.
Wait for an async element to appear when performing integration tests with enzyme. Returns a promise which resolves with the root component you performed your search on.
NEW: There is now a fully working example using both Promises and async/await.
createWaitForElement(
enzymeSelector,
/*Optional*/ timeOut,
/*Optional*/ intervalDuration
)(componentToSearchOn)
.then(/* ... */)
.catch(/* ... */)
import React from 'react';
import { mount } from 'enzyme'
import { createWaitForElement } from 'enzyme-wait';
/**
* The component you want to test. Assume it displays
* the string "ready" after performing some async action
* which takes time.
*/
import SampleComponent from '...';
const waitForSample = createWaitForElement('#sample-ready');
const component = mount(<SampleComponent />);
it('displays ready once it is ready', ()=> {
waitForSample(component)
.then( component => expect(component.text()).to.include('ready') );
});
The same as above but using async/await instead of Promises:
it('displays ready once it is ready', async ()=> {
const componentReady = await waitForSample(component);
expect(componentReady.text()).to.include('ready');
});
If you have multiple async actions happening, just make sure to always return a Promise which resolves with the root component. This way you can create nice looking chains and avoid callback hell.
Example:
const component = mount(<SampleComponent />);
it('displays ready after multiple interactions', ()=> {
createWaitForElement('#sample-ready')(component)
.then( /* do something and return a resolved promise with the comp */ )
.then( /* do something and return a resolved promise with the comp */ )
.then( createWaitForElement('#another-component-ready') )
.then( component => expect(component.text().to.include('ready') );
});
There is now a working example inside this repo using both the Promise-approach as well as the async/await-approach.
The example uses Jest, but it should work with any test framework. In other frameworks you might need to call done() on asynchronous tests.
To play around with this example you can:
npm install && npm run dist
on the root repo (this is required to create a lib version of this package which is listed in the example's dependencies )cd example
npm install && npm start
http://localhost:9000
to see the example or run npm test
to see the tests working.FAQs
Wait for an async element to appear when performing integration tests with enzyme.
The npm package @oskarer/enzyme-wait receives a total of 24 weekly downloads. As such, @oskarer/enzyme-wait popularity was classified as not popular.
We found that @oskarer/enzyme-wait demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.