Skip to content

Commit 62d3501

Browse files
authored
fix(artifacts): by default take appNotReady screenshot (wix#1997)
1 parent 42ebe38 commit 62d3501

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

detox/src/artifacts/screenshot/ScreenshotArtifactPlugin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const _ = require('lodash');
12
const TwoSnapshotsPerTestPlugin = require('../templates/plugin/TwoSnapshotsPerTestPlugin');
23

34
/***
@@ -6,6 +7,10 @@ const TwoSnapshotsPerTestPlugin = require('../templates/plugin/TwoSnapshotsPerTe
67
class ScreenshotArtifactPlugin extends TwoSnapshotsPerTestPlugin {
78
constructor({ api }) {
89
super({ api });
10+
11+
_.defaults(this.takeAutomaticSnapshots, {
12+
appNotReady: true,
13+
})
914
}
1015

1116
async preparePathForSnapshot(testSummary, name) {

detox/src/artifacts/screenshot/ScreenshotArtifactPlugin.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
const ScreenshotArtifactPlugin = require('./ScreenshotArtifactPlugin');
22

33
describe('ScreenshotArtifactPlugin', () => {
4+
describe('default options', () => {
5+
it('should have takeAutomaticSnapshots.appReady = true', () => {
6+
const plugin = new ScreenshotArtifactPlugin({
7+
api: {
8+
userConfig: {
9+
takeWhen: {},
10+
},
11+
}
12+
});
13+
14+
expect(plugin.takeAutomaticSnapshots.appNotReady).toBe(true);
15+
});
16+
17+
it('should allow to set takeAutomaticSnapshots.appReady to false', () => {
18+
const plugin = new ScreenshotArtifactPlugin({
19+
api: {
20+
userConfig: {
21+
takeWhen: {
22+
appNotReady: false,
23+
},
24+
},
25+
}
26+
});
27+
28+
expect(plugin.takeAutomaticSnapshots.appNotReady).toBe(false);
29+
});
30+
});
31+
432
describe('static parseConfig(config)', () => {
533
const parseConfig = ScreenshotArtifactPlugin.parseConfig;
634

0 commit comments

Comments
 (0)