17.1.1 • Published 2 months ago

@wixc3/testing v17.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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

FunctionDescription
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

InterfaceDescription
InfoStep info base, added step errors
PollDefaultsDefaults for poll steps
PromiseStep
PromiseWithTimeoutWithTimeout API
StepBaseCommon step props
StepsDefaultsTest step defaults
TimeoutDefaultsStep timeout defaults

Variables

VariableDescription
codeMatchers
DEFAULT_DISPOSAL_GROUP

Type Aliases

Type AliasDescription
DescriptionSets step description
PredicateA predicate functionAny return value other than **false** or throwing is considered as satisfying the predicate
RetryOptionsThe 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.
StubA generated stub
TimeoutSets step timeout
17.1.1

2 months ago

17.0.0

2 months ago

17.1.0

2 months ago

16.4.0

2 months ago

16.3.0

2 months ago

16.2.1

2 months ago

16.2.0

3 months ago

16.1.3

4 months ago

16.1.1

4 months ago

16.1.2

4 months ago

16.1.0

4 months ago

16.0.0

4 months ago

15.3.0

4 months ago

15.3.1

4 months ago

15.2.0

4 months ago

15.1.1

5 months ago

15.1.0

5 months ago

15.0.0

5 months ago

14.1.4

5 months ago

14.1.1

5 months ago

14.1.2

5 months ago

14.1.3

5 months ago

14.1.0

5 months ago

14.0.0

5 months ago

13.3.1

9 months ago

13.3.2

8 months ago

13.3.0

9 months ago

13.1.0

10 months ago

12.0.3

11 months ago

12.0.1

11 months ago

12.0.2

11 months ago

11.2.0

11 months ago

13.4.0

6 months ago

13.2.0

10 months ago

13.0.0

10 months ago

13.0.1

10 months ago

12.1.0

10 months ago

12.1.1

10 months ago

11.1.1

11 months ago

11.3.0

11 months ago

11.1.0

11 months ago

11.0.0

11 months ago

9.2.1

11 months ago

10.0.0

11 months ago

9.1.0

11 months ago

8.2.1

12 months ago

9.2.0

11 months ago

9.0.0

11 months ago

8.1.0

1 year ago

7.2.0

1 year ago

8.0.0

1 year ago

8.2.0

1 year ago

7.1.0

1 year ago

7.0.5

1 year ago

7.0.4

1 year ago

7.0.3

1 year ago

7.0.0

1 year ago

6.4.1

1 year ago

6.4.0

1 year ago

6.3.0

1 year ago

6.2.0

1 year ago

6.1.0

1 year ago

6.0.0

1 year ago

5.6.1

1 year ago

5.5.3

1 year ago

5.5.2

1 year ago

5.5.0

1 year ago

5.4.3

1 year ago

5.4.2

1 year ago

5.4.1

1 year ago

5.4.0

1 year ago

5.3.0

1 year ago

5.2.6

1 year ago

5.2.4

1 year ago

5.2.3

1 year ago

5.2.2

1 year ago

5.2.1

1 year ago

5.2.0

1 year ago

5.1.0

1 year ago

5.0.3

1 year ago

5.0.2

1 year ago

5.0.1

1 year ago

5.0.0

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

3.5.1

1 year ago

3.5.0

1 year ago

3.4.1

1 year ago

3.4.0

1 year ago

3.3.1

1 year ago

3.3.0

1 year ago

3.2.3

1 year ago

3.2.2

1 year ago

3.2.1

1 year ago

3.2.0

1 year ago

3.1.0

1 year ago

3.0.5

1 year ago