Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed version for jest26 #27

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store

.npmrc
node_modules
**.tgz

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-mock-console",
"version": "1.2.0",
"version": "1.2.1",
"description": "Jest utility to mock the console",
"main": "index.js",
"types": "index.d.ts",
Expand Down Expand Up @@ -43,6 +43,9 @@
"ts-jest26": "npm:ts-jest@^26.5.6",
"typescript": "^4.2.4"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"repository": {
"type": "git",
"url": "https://github.com/bpedersen/jest-mock-console.git"
Expand Down
6 changes: 4 additions & 2 deletions src/setupTestFramework.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const originalDescribe = describe;

// Check to see if version before 27 where jasmine is default
const jestVersion = require("jest/package.json").version;
const [majorVersion] = jestVersion.split(".");
if (majorVersion < 27) {
const originalDescribe = jasmine.getEnv().describe;

jasmine.getEnv().describe = (
description,
specDefinitions,
Expand All @@ -26,6 +26,8 @@ if (majorVersion < 27) {
);
};
} else {
const originalDescribe = describe;

describe = (description, specDefinitions) => {
let $jestMockConsoleOriginal;
const injectedSpecDefinition = (...specArgs) => {
Expand Down