New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jest-test-each

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-test-each - npm Package Compare versions

Comparing version 0.8.11 to 0.9.0

9

dist/test-each-setup.d.ts

@@ -33,7 +33,10 @@ import { Env } from './test-env';

export declare const userEnv: {
env?: Env;
env?: Env & EnvHasPending;
};
export declare type EnvHasPending = {
envHasPending?: boolean;
};
export declare const testEnvDefault: () => {
env: Env;
env: Env & EnvHasPending;
};
export declare const TestEachEnv: (env: Env) => void;
export declare const TestEachEnv: (env: Partial<Env>) => void;

@@ -22,2 +22,12 @@ "use strict";

exports.userEnv = {};
const envHasPending = () => {
try {
// test-runner jest-jasmine2 has 'pending', jest-circus doesn't have
return !!pending;
}
catch (err) {
return String(err).indexOf('pending is not defined') === -1;
}
};
const envPending = envHasPending();
const testEnvDefault = () => ({

@@ -31,3 +41,8 @@ env: {

describe,
pending,
envHasPending: envPending,
pending: (reason) => {
if (envPending) {
return pending(reason);
}
},
},

@@ -37,4 +52,4 @@ });

const TestEachEnv = (env) => {
exports.userEnv.env = env;
exports.userEnv.env = Object.assign(Object.assign({}, exports.testEnvDefault().env), env);
};
exports.TestEachEnv = TestEachEnv;

@@ -54,5 +54,4 @@ /// <reference types="jest" />

private runEnsures;
private addName;
run(body: (each: Combined, before: BeforeT) => void): void;
}
export {};

@@ -161,24 +161,25 @@ "use strict";

// if it fails -> skip
try {
yield this.runBody(body, args, isBefore);
}
catch (err) {
let error = undefined;
yield this.runBody(body, args, isBefore)
.then(() => {
error = `Test doesn't fail but marked with defect`;
})
.catch(err => {
const alignedMessage = [stripAnsi(err.message), stripAnsi(err.stack)].join('\n');
const markPending = () => {
// check reasons
if (!reasons || reasons.every(r => alignedMessage.includes(r))) {
// todo test will pass with jest-circus- need a way to skip test from inside for jest-circus
this.env.pending(`Test marked with defect '${markedDefect}': Actual fail reason:\\n ${alignedMessage}`);
};
// check reasons
if (reasons) {
if (reasons.every(r => alignedMessage.includes(r))) {
markPending();
return;
}
}
if (reasons && !reasons.every(r => alignedMessage.includes(r))) {
throw new Error(`Actual fail reason doesn't contain [${reasons}]\nActual fail reason:\n "${alignedMessage}"`);
}
markPending();
return;
});
if (error) {
throw new Error(error);
}
throw new Error(`Test doesn't fail but marked with defect`);
}
yield this.runBody(body, args, isBefore);
else {
yield this.runBody(body, args, isBefore);
}
}));

@@ -221,5 +222,2 @@ }

}
addName(name) {
return this.testParentDesc ? `${this.testParentDesc} ${name}` : name;
}
run(body) {

@@ -243,3 +241,5 @@ const { groupBySuites, testSuiteName, groupParentBySuite } = this.conf;

const desc = mergedFullData.flatDesc || ((_a = this.flatDescFunc) === null || _a === void 0 ? void 0 : _a.call(this, mergedFullData));
const flatDesc = { flatDesc: desc };
const flatDesc = {
flatDesc: groupParentBySuite ? desc : desc ? `${this.testParentDesc} ${desc}` : undefined,
};
const fullData = [...fullDatNoFlatDesc, flatDesc.flatDesc ? flatDesc : []];

@@ -250,4 +250,4 @@ const partialData = [currentTest.partialData, additionalData];

if (!groupBySuites && !groupParentBySuite) {
newName.name = this.addName(newName.name);
nameCaseFull.name = this.addName(nameCaseFull.name);
newName.name = `${this.testParentDesc} ${newName.name}`;
nameCaseFull.name = `${this.testParentDesc} ${nameCaseFull.name}`;
}

@@ -258,4 +258,4 @@ const testCase = Object.assign(Object.assign({}, currentTest), { data: utils_1.merge(fullData), name: newName, partialData: utils_1.merge(partialData) });

});
root.children.forEach(n => (n.name = groupParentBySuite ? n.name : this.addName(n.name)));
root.tests.forEach(n => (n.name.name = groupParentBySuite ? n.name.name : this.addName(n.name.name)));
root.children.forEach(n => (n.name = groupParentBySuite ? n.name : `${this.testParentDesc} ${n.name}`));
root.tests.forEach(n => (n.name.name = groupParentBySuite ? n.name.name : `${this.testParentDesc} ${n.name.name}`));
const isFlat = allCases.every(p => p.isFlat);

@@ -262,0 +262,0 @@ if (this.onlyOne) {

{
"name": "jest-test-each",
"version": "0.8.11",
"version": "0.9.0",
"description": "run parametrised tests easily [typesafe] without text tables or arrays of arrays.",

@@ -32,7 +32,8 @@ "main": "./dist/index.js",

"devDependencies": {
"@types/jest": "^26.0.22",
"jest": "^26.6.3",
"@types/jest": "^26.0.23",
"jest": "^27.0.1",
"jest-jasmine2": "^27.0.3",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"ts-jest": "^26.5.4",
"ts-jest": "^27.0.1",
"tslib": "^2.1.0",

@@ -39,0 +40,0 @@ "typescript": "^4.2.3"

@@ -170,3 +170,18 @@ # jest-test-each

### 0.9.0
Supporting jest 27.
Working with Skip and Defect:
1. When using test-runner 'jest-circus' (default runner in jest 27):
- defected tests which fail will not be marked skipped as it was before, it will be marked as passed.
- defected tests which passed will fail as before
- skipping test will not run test but it will be marked as passed
2. When using test runner 'jest-jasmine2' everything will be as before.
You can add the following in jest.config.js to use 'jest-jasmine2' runner:
```json
test-runner: "jest-jasmine2"
```
### 0.8.8
- Ability to add flatDesc to cases simplier - as function for each (.each(..).desc(t=>...))

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc