npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wixc3/testing

v17.1.1

Published

Making mocha/chai testing easier

Downloads

3,303

Readme

npm version @wixc3/testing on Github

Home > @wixc3/testing

testing package

Utils for making mocha + chai testing easy and fun

Remarks

Env variables

  • 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

Test timeout manipulation

  • 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

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

Available steps:

Functions

| 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 orderTo 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 |

Interfaces

| 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 |

Variables

| Variable | Description | | -------------------------------------------------------------------------------------------------- | ----------- | | codeMatchers | | | DEFAULT_DISPOSAL_GROUP | |

Type Aliases

| Type Alias | Description | | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Description | Sets step description | | Predicate | A predicate functionAny return value other than **false** or throwing is considered as satisfying the predicate | | RetryOptions | The retry options for the chaiRetryPlugin. {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 |