Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Bug-fixes within the same version aren't needed

* upgrade to the latest jest version (24.7.x) - connectdotz

* `Settings.settings` no longer contains the default configuration but starts with `undefined` - stephtr

Before accessing this property, one has to run `Settings.getConfig`.

-->

### 25.0.0
Expand Down
14 changes: 9 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ export class Runner extends EventEmitter {
runJestWithUpdateForSnapshots(completion: () => void, args?: string[]): void;
}

export interface ConfigRepresentation {
testRegex: string | string[],
testMatch: string[],
};

export class Settings extends EventEmitter {
constructor(workspace: ProjectWorkspace, options?: Options);
getConfig(completed: Function): void;
getConfigs(completed: Function): void;
getConfig(completed: Function, index?: number): void;
jestVersionMajor: number | null;
settings: {
testRegex: string,
testMatch: string[],
};
configs: ConfigRepresentation[];
settings?: ConfigRepresentation;
}

export class ProjectWorkspace {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"dependencies": {
"@babel/traverse": "^7.1.2",
"babylon": "^6.14.1",
"jest-config": "^24.7.0",
"jest-snapshot": "^24.7.0",
"typescript": "^3.4.3"
},
Expand Down
14 changes: 2 additions & 12 deletions src/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,14 @@

import {ChildProcess} from 'child_process';
import EventEmitter from 'events';
import {defaults as jestConfigDefaults} from 'jest-config';
import type {Options, SpawnOptions} from './types';
import ProjectWorkspace from './project_workspace';
import {createProcess} from './Process';

// This class represents the the configuration of Jest's process
// we want to start with the defaults then override whatever they output
// the interface below can be used to show what we use, as currently the whole
// settings object will be in memory.

// Ideally anything you care about adding should have a default in
// the constructor see https://jestjs.io/docs/configuration.html
// for full deets

// For now, this is all we care about inside the config

type Glob = string;
Expand All @@ -43,7 +37,7 @@ export default class Settings extends EventEmitter {

configs: ConfigRepresentations;

settings: ConfigRepresentation;
settings: ?ConfigRepresentation;

workspace: ProjectWorkspace;

Expand All @@ -59,11 +53,7 @@ export default class Settings extends EventEmitter {
shell: options && options.shell,
};

const {testMatch, testRegex} = jestConfigDefaults;

this.settings = {testMatch, testRegex};

this.configs = [this.settings];
this.configs = [];
this._jsonPattern = new RegExp(/^[\s]*\{/gm);
}

Expand Down
1 change: 0 additions & 1 deletion src/__tests__/settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('Settings', () => {
};
const settings = new Settings(workspace, options);
expect(settings.workspace).toEqual(workspace);
expect(settings.settings).toEqual(expect.any(Object));
expect(settings.spawnOptions).toEqual(options);
});

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3264,7 +3264,7 @@ jest-cli@^24.7.1:
realpath-native "^1.1.0"
yargs "^12.0.2"

jest-config@^24.7.0, jest-config@^24.7.1:
jest-config@^24.7.1:
version "24.7.1"
resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-24.7.1.tgz#6c1dd4db82a89710a3cf66bdba97827c9a1cf052"
integrity sha512-8FlJNLI+X+MU37j7j8RE4DnJkvAghXmBWdArVzypW6WxfGuxiL/CCkzBg0gHtXhD2rxla3IMOSUAHylSKYJ83g==
Expand Down