Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
jest-plugin-context
Advanced tools
Adds context
as an alternative to describe
for jest.
Install jest-plugin-context
using yarn
:
yarn add --dev jest-plugin-context
RSpec took the ruby world by storm with its declarative method of TDD. In RSpec, describe
it used to wrap a set of tests against one functionality while context
is to wrap a set of tests against one functionality under the same state.
The difference being you should only describe
to test the User model and specifically describe
the #name
method. However, testing different states of the #name
method should use different context. You can view an example of this below.
If you want, you can import context
from jest-plugin-context
at the top of every test:
import context from 'jest-plugin-context';
If you want to install context
as a global, you can modify the jest
section of your package.json
to include:
"jest": {
"setupFiles": [
"jest-plugin-context/setup"
]
}
Here's an example test that uses context
:
describe('User', () => {
describe('#name', () => {
set('firstName', () => 'Harry');
set('lastName', () => 'Potter');
set('user', () => new User({firstName, lastName}));
context('with blank first name', () => {
set('firstName', () => null);
it('should return only the last name', () => {
expect(user.name).toEqual('Potter');
});
});
context('with blank last name', () => {
set('lastName', () => null);
it('should return only the first name', () => {
expect(user.name).toEqual('Harry');
});
});
});
});
FAQs
Adds context as an alternative to describe to jest.
The npm package jest-plugin-context receives a total of 9,634 weekly downloads. As such, jest-plugin-context popularity was classified as popular.
We found that jest-plugin-context 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
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.