You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

ava-fixture

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ava-fixture - npm Package Compare versions

Comparing version

to
0.2.2

56

dist/index.d.ts

@@ -41,12 +41,45 @@ import test, { Test, ContextualTestContext, ContextualCallbackTestContext, Observable, ContextualCallbackTest, ContextualTest } from 'ava';

export interface FixtureContextualTestFunction {
(title: string, fixtureName: string, run: FixtureContextualTest): void;
(fixtureName: string, run: FixtureContextualTest): void;
/**
* Runs a fixture test.
* @param title Title of the test (for display and filtering).
* @param caseName Name of the test case, matching the folder under `path`.
* @param run The test function.
*/
(title: string, caseName: string, run: FixtureContextualTest): void;
/**
* Runs a fixture test.
* @param caseName Name of the test case, matching the folder under `path`.
* @param run The test function.
*/
(caseName: string, run: FixtureContextualTest): void;
}
export interface FixtureContextualSerialTestFunction {
(title: string, fixtureName: string, run: FixtureContextualSerialTest): void;
(fixtureName: string, run: FixtureContextualSerialTest): void;
/**
* Runs a fixture test.
* @param title Title of the test (for display and filtering).
* @param caseName Name of the test case, matching the folder under `path`.
* @param run The test function.
*/
(title: string, caseName: string, run: FixtureContextualSerialTest): void;
/**
* Runs a fixture test.
* @param caseName Name of the test case, matching the folder under `path`.
* @param run The test function.
*/
(caseName: string, run: FixtureContextualSerialTest): void;
}
export interface FixtureContextualCallbackTestFunction {
(title: string, fixtureName: string, run: FixtureContextualCallbackTest): void;
(fixtureName: string, run: FixtureContextualCallbackTest): void;
/**
* Runs a fixture test.
* @param title Title of the test (for display and filtering).
* @param caseName Name of the test case, matching the folder under `path`.
* @param run The test function.
*/
(title: string, caseName: string, run: FixtureContextualCallbackTest): void;
/**
* Runs a fixture test.
* @param caseName Name of the test case, matching the folder under `path`.
* @param run The test function.
*/
(caseName: string, run: FixtureContextualCallbackTest): void;
}

@@ -66,6 +99,6 @@ export interface FixtureRunner extends FixtureContextualTestFunction {

todo(title: string): void;
only(title: string, fixtureName: string, run: (t: ContextualTestContext, path: string) => any): void;
only(fixtureName: string, run: (t: ContextualTestContext, path: string) => any): void;
skip(title: string, fixtureName: string, run: (t: ContextualTestContext, path: string) => any): void;
skip(fixtureName: string, run: (t: ContextualTestContext, path: string) => any): void;
only(title: string, caseName: string, run: (t: ContextualTestContext, path: string) => any): void;
only(caseName: string, run: (t: ContextualTestContext, path: string) => any): void;
skip(title: string, caseName: string, run: (t: ContextualTestContext, path: string) => any): void;
skip(caseName: string, run: (t: ContextualTestContext, path: string) => any): void;
after(title: string, run: (t: ContextualTestContext) => void): void;

@@ -80,5 +113,6 @@ after(run: (t: ContextualTestContext) => void): void;

* Creates fixture test.
* @param ava `ava` test (`import test from 'ava'`).
* `cwd` is set to the case directory during the test.
* @param ava The ava module function (`import ava from 'ava'`).
* @param path Absolute or relative path to the fixture cases parent directory.
*/
export default function fixture(ava: typeof test, path: string): FixtureTest;

29

dist/index.js

@@ -5,3 +5,4 @@ "use strict";

* Creates fixture test.
* @param ava `ava` test (`import test from 'ava'`).
* `cwd` is set to the case directory during the test.
* @param ava The ava module function (`import ava from 'ava'`).
* @param path Absolute or relative path to the fixture cases parent directory.

@@ -11,11 +12,25 @@ */

function curry(testfn) {
return (function (name, fixtureName, run) {
return (function (title, caseName, run) {
if (!run) {
// name is optional
run = fixtureName;
fixtureName = name;
run = caseName;
caseName = title;
}
var fixturePath = path_1.join(path, fixtureName);
return testfn((name ? name + ' ' : '') + "(fixture: " + fixtureName + ")", function (t) {
return run(t, fixturePath);
var fixturePath = path_1.resolve(path, caseName);
return testfn((title ? title + ' ' : '') + "(fixture: " + caseName + ")", function (t) {
var result;
var cwd = process.cwd();
try {
process.chdir(fixturePath);
result = run(t, fixturePath);
if (result && result.then) {
return result.then(function (r) {
process.chdir(cwd);
return r;
});
}
}
finally {
process.chdir(cwd);
}
});

@@ -22,0 +37,0 @@ });

{
"name": "ava-fixture",
"version": "0.2.1",
"version": "0.2.2",
"description": "Write fixture tests with ava",

@@ -5,0 +5,0 @@ "author": {

Sorry, the diff of this file is not supported yet