From 69bcc05b6314acaeabb3db466acc2a21fcc0c5f6 Mon Sep 17 00:00:00 2001 From: Valentin Agachi Date: Mon, 3 Dec 2018 10:21:58 +0000 Subject: [PATCH] fixup! Call environment setup/teardown with current path --- docs/Configuration.md | 6 +++--- e2e/test-environment-async/TestEnvironment.js | 6 +++--- types/Environment.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index aa86548b1159..5fe554c280cb 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -771,9 +771,9 @@ Example: const NodeEnvironment = require('jest-environment-node'); class CustomEnvironment extends NodeEnvironment { - constructor(config, options) { - super(config, options); - this.testPath = options.testPath; + constructor(config, context) { + super(config, context); + this.testPath = context.testPath; } async setup() { diff --git a/e2e/test-environment-async/TestEnvironment.js b/e2e/test-environment-async/TestEnvironment.js index 00ccb5f5f377..b2411a244576 100644 --- a/e2e/test-environment-async/TestEnvironment.js +++ b/e2e/test-environment-async/TestEnvironment.js @@ -10,13 +10,13 @@ const JSDOMEnvironment = require('jest-environment-jsdom'); const DIR = os.tmpdir() + '/jest-test-environment'; class TestEnvironment extends JSDOMEnvironment { - constructor(config, options) { + constructor(config, context) { super(config); - this.options = options; + this.context = context; } setup() { - console.info('TestEnvironment.setup:', this.options.testPath); + console.info('TestEnvironment.setup:', this.context.testPath); return super.setup().then(() => { this.global.setup = 'setup'; }); diff --git a/types/Environment.js b/types/Environment.js index cb66206d6f4c..237b47077532 100644 --- a/types/Environment.js +++ b/types/Environment.js @@ -12,13 +12,13 @@ import type {Global} from './Global'; import type {Script} from 'vm'; import type {ModuleMocker} from 'jest-mock'; -export type EnvironmentOptions = { +export type EnvironmentContext = { console?: Object, testPath?: string, }; declare class $JestEnvironment { - constructor(config: ProjectConfig, options?: EnvironmentOptions): void; + constructor(config: ProjectConfig, context?: EnvironmentContext): void; runScript(script: Script): any; global: Global; fakeTimers: {