Skip to content

Commit

Permalink
fixup! Call environment setup/teardown with current path
Browse files Browse the repository at this point in the history
  • Loading branch information
avaly committed Dec 3, 2018
1 parent 803db5c commit 69bcc05
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions e2e/test-environment-async/TestEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
});
Expand Down
4 changes: 2 additions & 2 deletions types/Environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 69bcc05

Please sign in to comment.