Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed May 13, 2022
1 parent a8e812c commit 1690329
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions detox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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/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: 1 addition & 4 deletions docs/Guide.Jest.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ As already mentioned in the [Getting Started](Introduction.GettingStarted.md#set

By the way, Jest itself — much like Detox, also does not effectively run any tests. Instead, it is more of a dispatcher and orchestrator of multiple instances of a delegated runner capable of running in parallel. For more info, refer to [this video](https://youtu.be/3YDiloj8_d0?t=2127) (source: [Jest architecture](https://jestjs.io/docs/en/architecture)).

For its part, Detox supports only one Jest’s concrete runner, which is [`jest-circus`](https://www.npmjs.com/package/jest-circus) ([ships by default with Jest since 27.0.0](https://jestjs.io/blog/2021/05/25/jest-27)). The former runner, `jest-jasmine2`, is deprecated due to specific bugs in the past, and architectural limitations at present.

### Installation

**Disclaimer:**

1. Here we focus on installing Detox on _new projects_. If you’re migrating a project with an existing Detox installation, please apply some common sense while using this guide.
1. These instructions are relevant for `jest@^27.0.0` (and `jest@^26.0.1 + jest-circus@^26.0.1`). They should likely work for the newer `jest` versions too, but for **the older ones** (25.x, 24.x) — **they will not, due to blocking issues.**
1. These instructions are relevant for `jest@^27.2.5` and `jest@28.x.x`. They should likely work for the newer `jest` versions too, but for **the older ones** (26.x, 25.x) — **they will not, due to blocking issues.**

#### 1. Install Jest

Expand All @@ -38,7 +36,6 @@ npm install -D "jest@>=27.2.5"

**NOTE:** The command will install the _latest Jest version_. However, `@>=27.2.5` addendum is recommended just to be on the safe side in a common scenario, when a `package-lock.json`
generated by an official React Native project template limits Jest version to a very old `26.x`, maybe due to some optimization mechanism.
Generally we recommend not to stay on outdated Jest versions for too long, e.g. `jest@27.2.5` will be the minimal version supported by Detox 20.

#### 2. Set up Test-code Scaffolds

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-react-native-jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"detox": "^19.6.8",
"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 1690329

Please sign in to comment.