Skip to content

Commit

Permalink
Remove property checks and import defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
lekterable committed Feb 5, 2019
1 parent 3b48d87 commit 21f8476
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
3 changes: 2 additions & 1 deletion packages/jest-runtime/src/__tests__/instrumentation.test.js
Expand Up @@ -12,7 +12,7 @@ import vm from 'vm';
import path from 'path';
import os from 'os';
import ScriptTransformer from '../ScriptTransformer';
import {normalize} from 'jest-config';
import {normalize, defaults} from 'jest-config';

jest.mock('vm');

Expand All @@ -24,6 +24,7 @@ const FILE_PATH_TO_INSTRUMENT = path.resolve(
it('instruments files', () => {
const config = normalize(
{
...defaults,
cache: false,
cacheDirectory: os.tmpdir(),
rootDir: '/',
Expand Down
Expand Up @@ -8,7 +8,7 @@

'use strict';

import {normalize} from 'jest-config';
import {normalize, defaults} from 'jest-config';

jest
.mock('fs', () =>
Expand Down Expand Up @@ -190,6 +190,7 @@ describe('ScriptTransformer', () => {

config = normalize(
{
...defaults,
cache: true,
cacheDirectory: '/cache/',
name: 'test',
Expand Down
25 changes: 8 additions & 17 deletions packages/jest-runtime/src/__tests__/should_instrument.test.js
Expand Up @@ -4,32 +4,23 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import type {Path, ProjectConfig} from 'types/Config';
import type {Options} from '../ScriptTransformer';

import {normalize} from 'jest-config';
import {normalize, defaults} from 'jest-config';
import shouldInstrument from '../shouldInstrument';

describe('shouldInstrument', () => {
const defaultFilename = 'source_file.test.js';
const defaultOptions = {
collectCoverage: true,
};
const defaultConfig = normalize(
{
rootDir: '/',
},
{},
).options;
const defaultConfig = normalize({...defaults, rootDir: '/'}, {}).options;

describe('should return true', () => {
const testShouldInstrument = (
filename: Path = defaultFilename,
options: Options,
config: ProjectConfig,
filename = defaultFilename,
options,
config,
) => {
const result = shouldInstrument(
filename,
Expand Down Expand Up @@ -126,9 +117,9 @@ describe('shouldInstrument', () => {

describe('should return false', () => {
const testShouldInstrument = (
filename: Path = defaultFilename,
options: Options,
config: ProjectConfig,
filename = defaultFilename,
options,
config,
) => {
const result = shouldInstrument(
filename,
Expand Down

0 comments on commit 21f8476

Please sign in to comment.