Upgrade Ava to v4
This commit is contained in:
parent
9a40cc5274
commit
ce89f1b611
1153 changed files with 27264 additions and 95308 deletions
52
node_modules/ava/lib/create-chain.js
generated
vendored
52
node_modules/ava/lib/create-chain.js
generated
vendored
|
|
@ -1,4 +1,3 @@
|
|||
'use strict';
|
||||
const chainRegistry = new WeakMap();
|
||||
|
||||
function startChain(name, call, defaults) {
|
||||
|
|
@ -48,20 +47,16 @@ function createHookChain(hook, isAfterHook) {
|
|||
// * `skip` must come at the end
|
||||
// * no `only`
|
||||
// * no repeating
|
||||
extendChain(hook, 'cb', 'callback');
|
||||
extendChain(hook, 'skip', 'skipped');
|
||||
extendChain(hook.cb, 'skip', 'skipped');
|
||||
if (isAfterHook) {
|
||||
extendChain(hook, 'always');
|
||||
extendChain(hook.always, 'cb', 'callback');
|
||||
extendChain(hook.always, 'skip', 'skipped');
|
||||
extendChain(hook.always.cb, 'skip', 'skipped');
|
||||
}
|
||||
|
||||
return hook;
|
||||
}
|
||||
|
||||
function createChain(fn, defaults, meta) {
|
||||
export default function createChain(fn, defaults, meta) {
|
||||
// Test chaining rules:
|
||||
// * `serial` must come at the start
|
||||
// * `only` and `skip` must come at the end
|
||||
|
|
@ -69,27 +64,15 @@ function createChain(fn, defaults, meta) {
|
|||
// * `only` and `skip` cannot be chained together
|
||||
// * no repeating
|
||||
const root = startChain('test', fn, {...defaults, type: 'test'});
|
||||
extendChain(root, 'cb', 'callback');
|
||||
extendChain(root, 'failing');
|
||||
extendChain(root, 'only', 'exclusive');
|
||||
extendChain(root, 'serial');
|
||||
extendChain(root, 'skip', 'skipped');
|
||||
extendChain(root.cb, 'failing');
|
||||
extendChain(root.cb, 'only', 'exclusive');
|
||||
extendChain(root.cb, 'skip', 'skipped');
|
||||
extendChain(root.cb.failing, 'only', 'exclusive');
|
||||
extendChain(root.cb.failing, 'skip', 'skipped');
|
||||
extendChain(root.failing, 'only', 'exclusive');
|
||||
extendChain(root.failing, 'skip', 'skipped');
|
||||
extendChain(root.serial, 'cb', 'callback');
|
||||
extendChain(root.serial, 'failing');
|
||||
extendChain(root.serial, 'only', 'exclusive');
|
||||
extendChain(root.serial, 'skip', 'skipped');
|
||||
extendChain(root.serial.cb, 'failing');
|
||||
extendChain(root.serial.cb, 'only', 'exclusive');
|
||||
extendChain(root.serial.cb, 'skip', 'skipped');
|
||||
extendChain(root.serial.cb.failing, 'only', 'exclusive');
|
||||
extendChain(root.serial.cb.failing, 'skip', 'skipped');
|
||||
extendChain(root.serial.failing, 'only', 'exclusive');
|
||||
extendChain(root.serial.failing, 'skip', 'skipped');
|
||||
|
||||
|
|
@ -108,9 +91,38 @@ function createChain(fn, defaults, meta) {
|
|||
root.todo = startChain('test.todo', fn, {...defaults, type: 'test', todo: true});
|
||||
root.serial.todo = startChain('test.serial.todo', fn, {...defaults, serial: true, type: 'test', todo: true});
|
||||
|
||||
root.macro = options => {
|
||||
if (typeof options === 'function') {
|
||||
return Object.freeze({exec: options});
|
||||
}
|
||||
|
||||
return Object.freeze({exec: options.exec, title: options.title});
|
||||
};
|
||||
|
||||
root.meta = meta;
|
||||
|
||||
// Our type definition uses ESM syntax; when using CJS with VSCode, the
|
||||
// auto-completion assumes the root is accessed through `require('ava').default`.
|
||||
// Placate VSCode by adding a mostly hidden default property on the root.
|
||||
// This is available through both CJS and ESM imports. We use a proxy so that
|
||||
// we don't end up with root.default.default.default chains.
|
||||
Object.defineProperty(root, 'default', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: new Proxy(root, {
|
||||
apply(target, thisArg, argumentsList) {
|
||||
target.apply(thisArg, argumentsList);
|
||||
},
|
||||
get(target, prop) {
|
||||
if (prop === 'default') {
|
||||
throw new TypeError('Cannot access default.default');
|
||||
}
|
||||
|
||||
return target[prop];
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
module.exports = createChain;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue