
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
@wixc3/testing
Advanced tools
Utils for making mocha + chai testing easy and fun
DEBUG=true/positive number env variable will set test timeouts and time scale to infinity so tests (that don't explicitly override timeout) will not time out on breakpoints
TIMEOUT_MULTIPLIER=number env variable will multiply all test timeouts by the given number
scaleTimeout() multiplies timeouts when debugging or running on slow CI machines, based on TIMEOUT_MULTIPLIER and DEBUG env variables
adjusts current test timeout (for use in non step async actions)
locatorTimeout() creates a locator timeout and adjust the current test
Steps are a convenient way to craft async tests. A step has a timeout and a description, making test timeouts easy to understand and debug. Each step timeout auto increases the test timeout, assuring the step will time out before the test
withTimeout() adds timeout and description to a promise
allWithTimeout() time limited Promise.all
waitForSpyCall() spies on a method and wait for first call
waitForStubCall() creates a one off stub and wait for it to be called
step() adds a description (but not timeout) to a promise, useful for playwright locator waitFor
sleep() sleep (and adjust test time)
| Function | Description |
|---|---|
| adjustCurrentTestTimeout(ms) | Add ms to current test timeout |
| adjustTestsTimeouts() | Adjust tests timeouts based on DEBUG and TIMEOUT_MULTIPLIER environment variables |
| allWithTimeout(actions) | Limits the time a list of promises can take - Note: useable only within a mocha test/hook. The total test timeout will be adjusted to make sure the test will not time out waiting for this step |
| chaiRetryPlugin(_, { flag, inspect }) | Plugin that allows to re-run function passed to expect, in order to achieve that use new retry method, retrying would be performed until the result will pass the chained assertion or timeout exceeded or retries limit reached. Should be applied through Chai.use function, for example: |
| createDisposalGroup(name, constraints) | Creates a new disposal group |
| createTestDisposables(disposeHook) | Creates a disposable group that will be disposed after the test is done |
| debugSafeTimeout(ms, rest) | Creates an object with scaled timeout and adjust the current test timeout accordingly |
| defaults() | default values for steps of the current test |
| disposeAfter(disposable, options) | |
| getTimeoutScale() | |
| initAndDisposeAfter(target, options, args) | |
| isDebugMode() | |
| locatorTimeout(ms) | |
| mochaCtx() | Active mocha context |
| overrideDebugMode(value) | override the DEBUG environment variable for the current test |
| overrideTimeoutScale(scale) | Overrides the TIMEOUT_MULTIPLIER for the current test |
| randomizeTestsOrder(shouldRandomize) | Randomizes tests order To avoid confusion, it can only be set once, before the testing begins (i.e. not in a running test) |
| scaleTimeout(timeout) | Scales a timeout based on the TIMEOUT_MULTIPLIER and DEBUG environment variable |
| sleep(ms) | Resolves after ms milliseconds |
| step(action) | Adds a step description to a promise if it's rejected * - Note: useable only within a mocha test/hook. The total test timeout will be adjusted to make sure the test will not time out waiting for this step |
| useSafeFakeTimers() | Makes it easy to safely use fake timers |
| waitForSpyCall(scope, method) | Spies on an object method, waiting until it's called. The spy is removed once called |
| waitForStubCall(action, waitForAction) | Creates a stub, then waits for it to be called |
| withTimeout(action) | Limits the time a promise can take - Note: useable only within a mocha test/hook. The total test timeout will be adjusted to make sure the test will not time out waiting for this step |
| Interface | Description |
|---|---|
| Info | Step info base, added step errors |
| PollDefaults | Defaults for poll steps |
| PromiseStep | |
| PromiseWithTimeout | WithTimeout API |
| StepBase | Common step props |
| StepsDefaults | Test step defaults |
| TimeoutDefaults | Step timeout defaults |
| Variable | Description |
|---|---|
| codeMatchers | |
| DEFAULT_DISPOSAL_GROUP |
| Type Alias | Description |
|---|---|
| Description | Sets step description |
| Predicate | A predicate function Any return value other than **false** or throwing is considered as satisfying the predicate |
| RetryOptions | The retry options for the {Object} RetryOptions {number} [timeout] - The maximum duration in milliseconds to wait before failing the retry operation. {number} [retries] - The number of times to retry the function before failing. {number} [delay] - The delay in milliseconds between retries. |
| Stub | A generated stub |
| Timeout | Sets step timeout |
FAQs
Making mocha/chai testing easier
The npm package @wixc3/testing receives a total of 8 weekly downloads. As such, @wixc3/testing popularity was classified as not popular.
We found that @wixc3/testing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 71 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.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.