Skip to content

Commit

Permalink
chore: upgrade internally to jest@28 (#3395)
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed May 31, 2022
1 parent 97f87f3 commit cb30415
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 51 deletions.
4 changes: 2 additions & 2 deletions detox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"eslint-plugin-no-only-tests": "^2.6.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-unicorn": "^39.0.0",
"jest": "^27.0.0",
"jest-environment-node": "^27.0.0",
"jest": "^28.0.0",
"mocha": ">=6.0.0",
"mockdate": "^2.0.1",
"prettier": "1.7.0",
Expand Down Expand Up @@ -78,6 +77,7 @@
"which": "^1.3.1",
"ws": "^7.0.0",
"yargs": "^16.0.3",
"yargs-parser": "^20.2.2",
"yargs-unparser": "^2.0.0"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion detox/runners/jest-circus/environment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-nocheck
const maybeNodeEnvironment = require('jest-environment-node'); // eslint-disable-line node/no-unpublished-require
const maybeNodeEnvironment = require('jest-environment-node'); // eslint-disable-line node/no-extraneous-require
const NodeEnvironment = maybeNodeEnvironment.default || maybeNodeEnvironment;

const DetoxError = require('../../src/errors/DetoxError');
Expand Down
2 changes: 1 addition & 1 deletion detox/runners/jest/JestCircusEnvironment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const maybeNodeEnvironment = require('jest-environment-node'); // eslint-disable-line node/no-unpublished-require
const maybeNodeEnvironment = require('jest-environment-node'); // eslint-disable-line node/no-extraneous-require
// @ts-ignore
const NodeEnvironment = maybeNodeEnvironment.default || maybeNodeEnvironment;

Expand Down
2 changes: 1 addition & 1 deletion detox/src/configuration/composeAppsConfig.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck
const _ = require('lodash');
const parse = require('yargs/yargs').Parser;
const parse = require('yargs-parser');

const deviceAppTypes = require('./utils/deviceAppTypes');

Expand Down
15 changes: 7 additions & 8 deletions detox/src/utils/callsites.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,19 @@ describe('callsites', () => {
const callStackDumpFromWrapperFn = (endFrame) => callsites.getStackDump(endFrame);
const callStackDumpFromTwoWrapperFn = (endFrame) => callStackDumpFromWrapperFn(endFrame);

const expectedTopFrameRegExp = /^ {4}at callStackDumpFromWrapperFn \(src[\\/]utils[\\/]callsites\.test\.js:[0-9][0-9]?:[0-9][0-9]?\)/;
const expected2ndLineRegExp = /^ {4}at callStackDumpFromTwoWrapperFn \(src[\\/]utils[\\/]callsites\.test\.js:[0-9][0-9]?:[0-9][0-9]?\)/;
const expectedTopFrameRegExp = /^ {4}at (?:Object\.)?callStackDumpFromWrapperFn \(src[\\/]utils[\\/]callsites\.test\.js:[0-9][0-9]?:[0-9][0-9]?\)/;
const expected2ndLineRegExp = /^ {4}at (?:Object\.)?callStackDumpFromTwoWrapperFn \(src[\\/]utils[\\/]callsites\.test\.js:[0-9][0-9]?:[0-9][0-9]?\)/;

it('should return a valid, multi-line, stack-dump string', () => {
const stackdump = callStackDumpFromTwoWrapperFn();
const [,line1,line2] = callStackDumpFromTwoWrapperFn().split('\n');

expect(stackdump).toEqual(expect.stringMatching(expectedTopFrameRegExp));
expect(stackdump).toEqual(expect.stringMatching(new RegExp(expected2ndLineRegExp, 'm')));
expect(line1).toEqual(expect.stringMatching(expectedTopFrameRegExp));
expect(line2).toEqual(expect.stringMatching(expected2ndLineRegExp));
});

it('should slice according to end-frame arg', () => {
const _expectedTopLineRegExp = expected2ndLineRegExp;
const stackdump = callStackDumpFromTwoWrapperFn(1);
expect(stackdump).toEqual(expect.stringMatching(_expectedTopLineRegExp));
const [,line1] = callStackDumpFromTwoWrapperFn(1).split('\n');
expect(line1).toEqual(expect.stringMatching(expected2ndLineRegExp));
});
});

Expand Down
10 changes: 7 additions & 3 deletions detox/src/utils/errorUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ describe('sliceErrorStack(error, fromIndex)', () => {
it('should clean up error stack by N first lines containing at:', () => {
function innerFunction() { throw new Error('Source Error'); }
function outerFunction() { innerFunction(); }
function attemptFunction() {
try { outerFunction(); } catch (e) { console.error('err', e); return e; }
}

const slicer = at => (_line) => --at < 0;
const error0 = errorUtils.filterErrorStack(_.attempt(outerFunction), slicer(0));
const error2 = errorUtils.filterErrorStack(_.attempt(outerFunction), slicer(1));
const error3 = errorUtils.filterErrorStack(_.attempt(outerFunction), slicer(2));
const error0 = errorUtils.filterErrorStack(attemptFunction(), slicer(1));
const error2 = errorUtils.filterErrorStack(attemptFunction(), slicer(2));
const error3 = errorUtils.filterErrorStack(attemptFunction(), slicer(3));
expect(error0.stack).toMatch(/at innerFunction/);
expect(error0.stack).toMatch(/at outerFunction/);
expect(error2.stack).not.toMatch(/at innerFunction/);
Expand Down
5 changes: 3 additions & 2 deletions examples/demo-plugin/e2e/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"setupFilesAfterEnv": ["./init.js"],
"testRunner": "jasmine2",
"maxWorkers": 1,
"reporters": ["detox/runners/jest/streamlineReporter"],
"testEnvironment": "detox/runners/jest-circus/environment",
"testTimeout": 120000,
"verbose": true
}
30 changes: 0 additions & 30 deletions examples/demo-plugin/e2e/init.js

This file was deleted.

2 changes: 1 addition & 1 deletion examples/demo-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"devDependencies": {
"detox": "^19.7.0",
"jest": "^27.0.0"
"jest": "^28.0.0"
},
"detox": {
"test-runner": "jest",
Expand Down
4 changes: 2 additions & 2 deletions examples/demo-react-native-jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"devDependencies": {
"@types/jest": "^27.0.3",
"detox": "^19.7.0",
"jest": "^27.0.0",
"jest": "^28.0.0",
"sanitize-filename": "^1.6.1",
"ts-jest": "^27.0.0",
"ts-jest": "^28.0.0",
"typescript": "^4.1.3"
},
"dependencies": {
Expand Down

0 comments on commit cb30415

Please sign in to comment.