jest-jasmine2
Advanced tools
Comparing version
@@ -17,6 +17,9 @@ /** | ||
const JasmineReporter = require('./reporter'); | ||
const expect = require('jest-matchers').expect; | ||
const fs = require('graceful-fs'); | ||
const jasminePit = require('./jasmine-pit'); | ||
const snapshot = require('jest-snapshot'); | ||
const JasmineReporter = require('./reporter'); | ||
const vm = require('vm'); | ||
@@ -27,5 +30,8 @@ const CALL_PRINT_LIMIT = 3; | ||
const JASMINE_CHECK_PATH = require.resolve('./jasmine-check'); | ||
const jasmineFileContent = | ||
fs.readFileSync(require.resolve(JASMINE_PATH), 'utf8'); | ||
const jasmineScript = new vm.Script(fs.readFileSync(JASMINE_PATH, 'utf8'), { | ||
displayErrors: true, | ||
filename: JASMINE_PATH }); | ||
function isSpyLike(test) { | ||
@@ -67,3 +73,3 @@ return test.calls && test.calls.all !== undefined;} | ||
environment.fakeTimers.runWithRealTimers(() => { | ||
environment.runSourceText(jasmineFileContent, JASMINE_PATH); | ||
environment.runScript(jasmineScript); | ||
@@ -99,4 +105,2 @@ const requireJasmine = environment.global.jasmineRequire; | ||
env = jasmine.getEnv(); | ||
env.snapshotState = snapshot.getSnapshotState(jasmine, testPath); | ||
const jasmineInterface = requireJasmine.interface(jasmine, env); | ||
@@ -166,8 +170,8 @@ Object.assign(environment.global, jasmineInterface); | ||
jasmine.addCustomEqualityTester(iterableEquality); | ||
jasmine.addMatchers( | ||
snapshot.getMatchers( | ||
testPath, | ||
config, | ||
jasmine, | ||
env.snapshotState)); | ||
jasmine.addMatchers({ | ||
toMatchSnapshot: snapshot.matcher( | ||
testPath, | ||
config, | ||
jasmine, | ||
snapshotState) }); | ||
@@ -297,2 +301,13 @@ | ||
// extend jasmine matchers with `jest-matchers` | ||
const jasmineExpect = env.expect; | ||
env.expect = actual => { | ||
const jasmineMatchers = jasmineExpect(actual); | ||
const jestMatchers = expect(actual); | ||
const not = Object.assign(jasmineMatchers.not, jestMatchers.not); | ||
return Object.assign(jasmineMatchers, jestMatchers, { not });}; | ||
const snapshotState = snapshot.getSnapshotState(jasmine, testPath); | ||
env.addReporter(reporter); | ||
@@ -302,3 +317,3 @@ runtime.requireModule(testPath); | ||
return reporter.getResults().then(results => { | ||
const currentSnapshot = env.snapshotState.snapshot; | ||
const currentSnapshot = snapshotState.snapshot; | ||
const updateSnapshot = config.updateSnapshot; | ||
@@ -313,6 +328,6 @@ const hasUncheckedKeys = currentSnapshot.hasUncheckedKeys(); | ||
results.snapshotFileDeleted = status.deleted; | ||
results.snapshotsAdded = env.snapshotState.added; | ||
results.snapshotsMatched = env.snapshotState.matched; | ||
results.snapshotsUnmatched = env.snapshotState.unmatched; | ||
results.snapshotsUpdated = env.snapshotState.updated; | ||
results.snapshotsAdded = snapshotState.added; | ||
results.snapshotsMatched = snapshotState.matched; | ||
results.snapshotsUnmatched = snapshotState.unmatched; | ||
results.snapshotsUpdated = snapshotState.updated; | ||
return results;});} | ||
@@ -319,0 +334,0 @@ |
{ | ||
"name": "jest-jasmine2", | ||
"version": "13.2.3", | ||
"version": "13.3.0-alpha.4eb0c908", | ||
"repository": { | ||
@@ -13,7 +13,9 @@ "type": "git", | ||
"jasmine-check": "^0.1.4", | ||
"jest-snapshot": "^13.2.3", | ||
"jest-util": "^13.2.2" | ||
"jest-matchers": "^13.3.0-alpha.4eb0c908", | ||
"jest-snapshot": "^13.3.0-alpha.4eb0c908", | ||
"jest-util": "^13.3.0-alpha.4eb0c908" | ||
}, | ||
"jest": { | ||
"rootDir": "./build", | ||
"rootDir": "./src", | ||
"scriptPreprocessor": "../../babel-jest", | ||
"testEnvironment": "node" | ||
@@ -20,0 +22,0 @@ }, |
Sorry, the diff of this file is not supported yet
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
107762
0.56%3198
0.31%5
25%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed