Detox configuration - Property 'getEnv' does not exist on type 'typeof jasmine'

Viewed 1029

Using this code in my setup.ts for detox caused error: TS2339: Property 'getEnv' does not exist on type 'typeof jasmine'. I have jest installed.

const detox = require('detox');
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');

jest.setTimeout(25000); 
jasmine.getEnv().addReporter(adapter)

beforeAll(async () => {
  await detox.init();
  await device.launchApp();
});

beforeEach(async () => {
  await adapter.beforeEach();
});

afterAll(async () => {
  await adapter.afterAll();
  await detox.cleanup();
});

2 Answers

when i moved on from npm to yarn perhaps i've broken my grey-box testing with Detox too.

yarn add -D typescript ts-jest
yarn add -D @types/detox @types/jest @types/jasmine

installs versions:

"@types/jasmine": "^3.6.9",
"jasmine": "^3.7.0",

i can use jasmine like that:

import Jasmine from 'jasmine';
const jasmine = new Jasmine(adapter);
jasmine.addReporter(adapter);

source code of Jasmine package in node_modules

try this fix

// tslint:disable-next-line:no-import-side-effect
import "jasmine";

jasmine.getEnv().addReporter(adapter);
Related