Skip to content

Commit

Permalink
Timeline self-integration testing (wix#2522)
Browse files Browse the repository at this point in the history
  • Loading branch information
d4vidi authored Dec 14, 2020
1 parent 5382d08 commit 50dc7e9
Show file tree
Hide file tree
Showing 24 changed files with 515 additions and 19 deletions.
3 changes: 2 additions & 1 deletion detox/src/DetoxExportWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const DetoxConstants = require('./DetoxConstants');
const configuration = require('./configuration');
const logger = require('./utils/logger');
const log = logger.child({ __filename });
const { traceCall } = require('./utils/trace');
const { trace, traceCall } = require('./utils/trace');

const _detox = Symbol('detox');
const _shouldLogInitError = Symbol('shouldLogInitError');
Expand Down Expand Up @@ -35,6 +35,7 @@ class DetoxExportWrapper {
async init(configOverride, userParams) {
let configError, exposeGlobals, resolvedConfig;

trace.init();
logger.reinitialize(Detox.global);

try {
Expand Down
19 changes: 15 additions & 4 deletions detox/src/artifacts/timeline/TimelineArtifactPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ const ArtifactPlugin = require('../templates/plugin/ArtifactPlugin');
const FileArtifact = require('../templates/artifact/FileArtifact');
const { trace } = require('../../utils/trace');
const ChromeTracingExporter = require('../../utils/ChromeTracingExporter');
const fakeTimestampsProvider = require('../../utils/fakeTimestampsProvider');

const traceStub = {
const traceNoop = {
startSection: _noop,
endSection: _noop,
};

class TimelineArtifactPlugin extends ArtifactPlugin {
constructor(config) {
super(config);
this._useFakeTimestamps = config.useFakeTimestamps;

this._trace = this.enabled ? trace : traceStub;
const threadId = process.env.JEST_WORKER_ID || process.pid;
this._trace = this.enabled ? trace : traceNoop;
this._traceExporter = new ChromeTracingExporter({
process: { id: 0, name: 'detox' },
thread: { id: process.pid, name: `Worker #${process.pid}` },
thread: { id: threadId, name: `Worker #${threadId}` },
});
}

Expand Down Expand Up @@ -57,7 +60,8 @@ class TimelineArtifactPlugin extends ArtifactPlugin {

const traceLogPath = await this.api.preparePathForArtifact(`detox.trace.json`);
const append = await this._logFileExists(traceLogPath);
const data = this._traceExporter.export(trace.events, append);
const events = this._useFakeTimestamps ? this._transformEventTimestamps(trace.events) : trace.events;
const data = this._traceExporter.export(events, append);

const fileArtifact = new FileArtifact({ temporaryData: data });
await fileArtifact.save(traceLogPath, { append });
Expand All @@ -67,6 +71,13 @@ class TimelineArtifactPlugin extends ArtifactPlugin {
return fs.access(traceLogPath).then(() => true).catch(() => false);
}

_transformEventTimestamps(events) {
return events.map((event) => ({
...event,
ts: fakeTimestampsProvider(),
}));
}

/** @param {string} config */
static parseConfig(config) {
return {
Expand Down
91 changes: 84 additions & 7 deletions detox/src/artifacts/timeline/TimelineArtifactPlugin.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const _ = require('lodash');

const latestInstanceOf = (clazz) => _.last(clazz.mock.instances);

describe('TimelineArtifactPlugin', () => {
Expand All @@ -17,6 +16,7 @@ describe('TimelineArtifactPlugin', () => {
let chromeTracingExporterObj;
let FileArtifact;
let fileArtifactObj;
let Trace;
let trace;
let TimelineArtifactPlugin;
let uutEnabled;
Expand All @@ -35,11 +35,12 @@ describe('TimelineArtifactPlugin', () => {
FileArtifact = require('../templates/artifact/FileArtifact');
fileArtifactObj = () => latestInstanceOf(FileArtifact);

const { Trace } = jest.genMockFromModule('../../utils/trace');
const mockTrace = new Trace();
const { Trace: MockTrace } = jest.genMockFromModule('../../utils/trace');
const mockTrace = new MockTrace();
jest.mock('../../utils/trace', () => ({
trace: mockTrace,
}));
Trace = MockTrace;
trace = mockTrace;

TimelineArtifactPlugin = require('./TimelineArtifactPlugin');
Expand Down Expand Up @@ -205,9 +206,10 @@ describe('TimelineArtifactPlugin', () => {
expect(fs.access).not.toHaveBeenCalled();
});

it('should properly init the trace-events exporter', async () => {
const expectedThreadId = process.pid;
const expectedThreadName = `Worker #${process.pid}`;
it('should properly init the trace-events exporter, and use the jest worker ID for thread-ID', async () => {
process.env.JEST_WORKER_ID = '102030';
const expectedThreadId = '102030';
const expectedThreadName = `Worker #102030`;
const uut = uutEnabled();

const exportedData = JSON.stringify({ mocked: 'mocked data' });
Expand All @@ -219,7 +221,82 @@ describe('TimelineArtifactPlugin', () => {
expect(ChromeTracingExporter).toHaveBeenCalledWith({
process: { id: 0, name: 'detox' },
thread: { id: expectedThreadId, name: expectedThreadName },
})
});
});

it('should resort to our pid as the exporter\'s thread-ID if not running using Jest', async () => {
process.env.JEST_WORKER_ID = '';
const expectedThreadId = process.pid;
const expectedThreadName = `Worker #${process.pid}`;
const uut = uutEnabled();

const exportedData = JSON.stringify({ mocked: 'mocked data' });
givenArtifactFileNotExists();
givenExportedTraceDataResult(exportedData);

await uut.onBeforeCleanup();

expect(ChromeTracingExporter).toHaveBeenCalledWith(expect.objectContaining({
thread: { id: expectedThreadId, name: expectedThreadName },
}));
});

it('should use trace events as inpute to data exporter', async () => {
trace.events = [
{ name: 'mock-event', type: 'start', ts: 1234},
{ name: 'mock-event', type: 'end', ts: 1235},
];
const uut = uutEnabled();

givenArtifactFileNotExists();
givenExportedTraceDataResult('mock');

await uut.onBeforeCleanup();

expect(chromeTracingExporterObj().export).toHaveBeenCalledWith(trace.events, false);
});

it('should pass in append=true to exporter if artifact file already exists', async () => {
trace.events = [];
const uut = uutEnabled();

givenArtifactFileAlreadyExists();
givenExportedTraceDataResult('mock');

await uut.onBeforeCleanup();

expect(chromeTracingExporterObj().export).toHaveBeenCalledWith([], true);
});

describe('In a stub-like operational mode', () => {
let uut;
beforeEach(() => {
uut = new TimelineArtifactPlugin({
...configMock({ enabled: true }),
useFakeTimestamps: true,
});
});

it('should rewrite the timeline events with fake (deterministic) timestamps', async () => {
const events = [
{ type: 'init', ts: 1233},
{ name: 'mock-event', type: 'start', ts: 1234},
{ name: 'mock-event', type: 'end', ts: 1235},
];
const expectedEvents = [
{ type: 'init', ts: 1000},
{ name: 'mock-event', type: 'start', ts: 1100},
{ name: 'mock-event', type: 'end', ts: 1200},
];
trace.events = events;

givenArtifactFileNotExists();
givenExportedTraceDataResult('mock');

await uut.onBeforeCleanup();

expect(chromeTracingExporterObj().export).toHaveBeenCalledWith(expectedEvents, false);
});
});
});

Expand Down
2 changes: 1 addition & 1 deletion detox/src/devices/drivers/android/AndroidDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AndroidDriver extends DeviceDriverBase {
log: (api) => new ADBLogcatPlugin({ api, adb, devicePathBuilder }),
screenshot: (api) => new ADBScreencapPlugin({ api, adb, devicePathBuilder }),
video: (api) => new ADBScreenrecorderPlugin({ api, adb, devicePathBuilder }),
timeline: (api) => new TimelineArtifactPlugin({api, adb, devicePathBuilder}),
timeline: (api) => new TimelineArtifactPlugin({ api }),
};
}

Expand Down
1 change: 0 additions & 1 deletion detox/src/matchersRegistry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ describe('Detox matchers registry', () => {

it('should init the Android-matchers with opts', () => {
withAndroidDevice();

uut.resolve(device, opts);
expect(AndroidExpect).toHaveBeenCalledWith(opts);
});
Expand Down
1 change: 1 addition & 0 deletions detox/src/utils/__mocks__/trace.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class FakeTrace {
constructor() {
this.init = jest.fn();
this.startSection = jest.fn();
this.endSection = jest.fn();
this.events = [];
Expand Down
9 changes: 9 additions & 0 deletions detox/src/utils/fakeTimestampsProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let _timestamp = 1000;

function nextTimestamp() {
const timestamp = _timestamp;
_timestamp += 100;
return timestamp;
}

module.exports = nextTimestamp;
8 changes: 8 additions & 0 deletions detox/src/utils/fakeTimestampsProvider.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe('Fake-timestamps provider', () => {
it('should provide timestamps in fixed intervals', () => {
const now = require('./fakeTimestampsProvider');
expect(now()).toEqual(1000);
expect(now()).toEqual(1100);
expect(now()).toEqual(1200);
});
});
8 changes: 6 additions & 2 deletions detox/src/utils/trace.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
class Trace {
constructor(timestampProviderFn = Date.now) {
constructor() {
this.events = [];
}

init(timestampProviderFn = Date.now) {
this._timestampProviderFn = timestampProviderFn;
this.events = [
this._event('init'),
Expand Down Expand Up @@ -30,7 +34,7 @@ class Trace {
}
}

const trace = new Trace();
let trace = new Trace();
async function traceCall(sectionName, func) {
trace.startSection(sectionName);
try {
Expand Down
15 changes: 12 additions & 3 deletions detox/src/utils/trace.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
describe('Trace util', () => {
const timestampProviderFn = () => 1234;

let Trace;
let uut;
beforeEach(() => {
const { Trace } = require('./trace');
uut = new Trace(timestampProviderFn);
Trace = require('./trace').Trace;
uut = new Trace();
uut.init(timestampProviderFn);
});

it('should produce an init event at creation time', () => {
it('should produce an empty events list upon creation', () => {
expect(new Trace().events).toEqual([]);
});

it('should produce an init event at init time', () => {
expect(uut.events).toEqual([{
type: 'init',
ts: 1234,
Expand Down Expand Up @@ -60,6 +66,7 @@ describe('Trace util', () => {

it('should export an instance', () => {
const { trace } = require('./trace');
trace.init();
trace.startSection('section1', {});
trace.endSection('section1', {});
trace.reset();
Expand Down Expand Up @@ -95,6 +102,7 @@ describe('Trace util', () => {
it('should trace a successful function', async () => {
const functionCall = () => Promise.resolve(42);

trace.init();
const result = await traceCall(sectionName, functionCall);
expect(trace.events).toEqual([
expect.any(Object),
Expand All @@ -109,6 +117,7 @@ describe('Trace util', () => {
const functionCall = () => Promise.reject(error);

try {
trace.init();
await traceCall(sectionName, functionCall);
fail('Expected an error');
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Timeline integration test should deterministically produce a timeline artifact 1`] = `"[{\\"name\\":\\"process_name\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":1000,\\"ph\\":\\"M\\",\\"args\\":{\\"name\\":\\"detox\\"}},{\\"name\\":\\"thread_name\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":1000,\\"ph\\":\\"M\\",\\"args\\":{\\"name\\":\\"Worker #2\\"}},{\\"name\\":\\"detoxInit\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":1100,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"acquireDevice\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":1200,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"acquireDevice\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":1300,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"appUninstall\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":1400,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"appUninstall\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":1500,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"appInstall\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":1600,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"appInstall\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":1700,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"launchApp\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":1800,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"launchApp\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":1900,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"detoxInit\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":2000,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"StubDevice#2\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":2100,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"Stub2\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":2200,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"should have welcome screen\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":2300,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":2400,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":2500,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"should have welcome screen\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":2600,\\"ph\\":\\"E\\",\\"args\\":{\\"status\\":\\"passed\\"}},{\\"name\\":\\"should show hello screen after tap\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":2700,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":2800,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":2900,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"should show hello screen after tap\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":3000,\\"ph\\":\\"E\\",\\"args\\":{\\"status\\":\\"passed\\"}},{\\"name\\":\\"Stub2\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":3100,\\"ph\\":\\"E\\",\\"args\\":{}},{\\"name\\":\\"StubDevice#2\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":3200,\\"ph\\":\\"E\\",\\"args\\":{}},{\\"name\\":\\"process_name\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":1000,\\"ph\\":\\"M\\",\\"args\\":{\\"name\\":\\"detox\\"}},{\\"name\\":\\"thread_name\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":1000,\\"ph\\":\\"M\\",\\"args\\":{\\"name\\":\\"Worker #1\\"}},{\\"name\\":\\"detoxInit\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":1100,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"acquireDevice\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":1200,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"acquireDevice\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":1300,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"appUninstall\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":1400,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"appUninstall\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":1500,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"appInstall\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":1600,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"appInstall\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":1700,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"launchApp\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":1800,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"launchApp\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":1900,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"detoxInit\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":2000,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"StubDevice#1\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":2100,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"Stub3\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":2200,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"should have welcome screen\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":2300,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":2400,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":2500,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"should have welcome screen\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":2600,\\"ph\\":\\"E\\",\\"args\\":{\\"status\\":\\"passed\\"}},{\\"name\\":\\"should show hello screen after tap\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":2700,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":2800,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":2900,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"should show hello screen after tap\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":3000,\\"ph\\":\\"E\\",\\"args\\":{\\"status\\":\\"passed\\"}},{\\"name\\":\\"should show world screen after tap\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":3100,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":3200,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":3300,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"should show world screen after tap\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":3400,\\"ph\\":\\"E\\",\\"args\\":{\\"status\\":\\"passed\\"}},{\\"name\\":\\"Stub3\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":3500,\\"ph\\":\\"E\\",\\"args\\":{}},{\\"name\\":\\"StubDevice#1\\",\\"pid\\":0,\\"tid\\":\\"1\\",\\"ts\\":3600,\\"ph\\":\\"E\\",\\"args\\":{}},{\\"name\\":\\"process_name\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":3300,\\"ph\\":\\"M\\",\\"args\\":{\\"name\\":\\"detox\\"}},{\\"name\\":\\"thread_name\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":3300,\\"ph\\":\\"M\\",\\"args\\":{\\"name\\":\\"Worker #2\\"}},{\\"name\\":\\"detoxInit\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":3400,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"acquireDevice\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":3500,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"acquireDevice\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":3600,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"appUninstall\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":3700,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"appUninstall\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":3800,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"appInstall\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":3900,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"appInstall\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":4000,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"launchApp\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":4100,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"launchApp\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":4200,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"detoxInit\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":4300,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"StubDevice#2\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":4400,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"Stub1\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":4500,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"should have welcome screen\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":4600,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":4700,\\"ph\\":\\"B\\",\\"args\\":{}},{\\"name\\":\\"reloadRN\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":4800,\\"ph\\":\\"E\\",\\"args\\":{\\"success\\":true}},{\\"name\\":\\"should have welcome screen\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":4900,\\"ph\\":\\"E\\",\\"args\\":{\\"status\\":\\"failed\\"}},{\\"name\\":\\"Stub1\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":5000,\\"ph\\":\\"E\\",\\"args\\":{}},{\\"name\\":\\"StubDevice#2\\",\\"pid\\":0,\\"tid\\":\\"2\\",\\"ts\\":5100,\\"ph\\":\\"E\\",\\"args\\":{}}"`;
6 changes: 6 additions & 0 deletions detox/test/integration/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
"testMatch": ["<rootDir>/*.test.js"],
"testTimeout": 120000,
"verbose": true,
"bail": false,
};
10 changes: 10 additions & 0 deletions detox/test/integration/e2e/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
"rootDir": "../..",
"testEnvironment": "../test/e2e/environment.js",
"testRunner": "../test/node_modules/jest-circus/runner",
"testMatch": ["<rootDir>/integration/e2e/*.test.js"],
"setupFilesAfterEnv": [],
"testTimeout": 120000,
"verbose": false,
"bail": false,
};
13 changes: 13 additions & 0 deletions detox/test/integration/e2e/stub1.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe('Stub1', () => {
beforeEach(async () => {
await device.reloadReactNative();
await element(by.text('Sanity')).tap();
});

it('should have welcome screen', async () => {
await expect(element(by.text('Welcome'))).toBeVisible();
await expect(element(by.text('Say Hello'))).toBeVisible();
await expect(element(by.text('Say World'))).toBeVisible();
throw new Error(`I'm only here to make things interesting!`);
});
});
Loading

0 comments on commit 50dc7e9

Please sign in to comment.