
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@valtech-commerce/jest-gwt
Advanced tools
Given-When-Then helper for Jest.
$ npm install @valtech-commerce/jest-gwt
Import the package in your Jest test files and extends the base GWT.
//--------------------------------------------------------
// xyz.gwt.js
//--------------------------------------------------------
import path from "node:path";
import { given as givenBase, when as whenBase, then as thenBase } from "@valtech-commerce/jest-gwt";
const given = { ...givenBase };
const when = { ...whenBase };
const then = { ...thenBase };
let rootPath;
given.noRootPath = () => {
rootPath = undefined;
};
given.rootPath = (value) => {
rootPath = value;
};
when.packageIsLoaded = () => {
when.attempting(() => {
require(path.join(rootPath, "package.json"));
});
};
export { given, when, then };
//--------------------------------------------------------
// xyz.test.js
//--------------------------------------------------------
import { given, when, then } from "./xyz.gwt";
describe("Validate package.json", () => {
beforeEach(() => {
given.noException();
given.noRootPath();
});
test("Ensure package can be loaded", () => {
given.rootPath("..");
when.packageIsLoaded();
then.shouldNotHaveThrown();
});
});
The package comes with multiple helpers. If you want them all, import the root package @valtech-commerce/jest-gwt
.
@valtech-commerce/jest-gwt/exception
Check for thrown exceptions
given.noException()
Reset exception listener
when.attempting(closure: Function)
Listen for error when executing closure
when.attemptingAsync(closure: Function)
Listen for error when executing asynchronous closure
then.shouldHaveThrown()
Exception has been thrown
then.shouldHaveThrownMessageContaining(message: string)
Exception, with message excerpt, has been thrown
then.shouldNotHaveThrown(closure: Function)
No exception has been thrown
@valtech-commerce/jest-gwt/package
Tests for package.json
given.noPackageRoot()
Reset root path
given.noPackageConfig()
Reset parsed config
given.noPackageNamePattern()
Reset name pattern
given.noPackageKeywords()
Reset keywords
given.packageRoot(value: string)
Specify the root path of the package.json
given.packageNamePattern(value: RegExp)
Specify a pattern for the package name
given.packageKeywords(value: string[])
Specify mandatory keywords
when.packageIsParsed()
Parse the package.json file
then.packageNameShouldBeValid()
Package name matches the defined name pattern
then.packageKeywordsShouldBeValid()
Package keywords contain at least the defined keywords
then.packageExportsShouldExist()
Package exports point to existing files
See the Changelog to see what has changed.
See the Contributing Guidelines for ways to get started.
See the Support Guide for ways to get help.
See the Security Policy for sharing vulnerability reports.
This project has a Code of Conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
[1.0.0] - 2023-02-22
FAQs
Given-When-Then helper for Jest
The npm package @valtech-commerce/jest-gwt receives a total of 2 weekly downloads. As such, @valtech-commerce/jest-gwt popularity was classified as not popular.
We found that @valtech-commerce/jest-gwt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.