Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize filenames in packages/jest circus #7301

Merged
merged 15 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from 13 commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@

### Chore & Maintenance

- `[jest-circus]` Standardize file naming in `jest-circus` ([#7301](https://github.com/facebook/jest/pull/7301))
- `[docs]` Add synchronous test.each setup ([#7150](https://github.com/facebook/jest/pull/7150))
- `[docs]` Add `this.extend` to the Custom Matchers API reference ([#7130](https://github.com/facebook/jest/pull/7130))
- `[docs]` Fix default value for `coverageReporters` value in configuration docs ([#7126](https://github.com/facebook/jest/pull/7126))
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
*/

// Allow people to use `jest-circus/runner` as a runner.
const runner = require('./build/legacy_code_todo_rewrite/jest_adapter');
const runner = require('./build/legacy-code-todo-rewrite/jest_adapter');
module.exports = runner;
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import {skipSuiteOnWindows} from '../../../../scripts/ConditionalTest';
const CIRCUS_PATH = require.resolve('../../build/index');
const CIRCUS_RUN_PATH = require.resolve('../../build/run');
const CIRCUS_STATE_PATH = require.resolve('../../build/state');
const TEST_EVENT_HANDLER_PATH = require.resolve('./test_event_handler');
const TEST_EVENT_HANDLER_PATH = require.resolve('./testEventHandler');
const BABEL_REGISTER_PATH = require.resolve('babel-register');

skipSuiteOnWindows();

export const runTest = (source: string) => {
export const testUtils = (source: string) => {
const filename = crypto
.createHash('md5')
.update(source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

'use strict';

import {runTest} from '../__mocks__/test_utils';
import {testUtils} from '../__mocks__/testUtils';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runTest was a good name, please revert

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll rename testUtils to runTest. Leave the filename testUtils?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, leave it was :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which files are left to rename?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

screenshot 2018-10-30 at 23 03 18

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good. I'll rename those as well


test('tests are not marked done until their parent afterAll runs', () => {
const {stdout} = runTest(`
const {stdout} = testUtils(`
describe('describe', () => {
afterAll(() => {});
test('one', () => {});
Expand All @@ -39,7 +39,7 @@ test('tests are not marked done until their parent afterAll runs', () => {
});

test('describe block cannot have hooks and no tests', () => {
const result = runTest(`
const result = testUtils(`
describe('describe', () => {
afterEach(() => {});
beforeEach(() => {});
Expand All @@ -52,7 +52,7 @@ test('describe block cannot have hooks and no tests', () => {
});

test('describe block _can_ have hooks if a child describe block has tests', () => {
const result = runTest(`
const result = testUtils(`
describe('describe', () => {
afterEach(() => console.log('> afterEach'));
beforeEach(() => console.log('> beforeEach'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

'use strict';

import {runTest} from '../__mocks__/test_utils';
import {testUtils} from '../__mocks__/testUtils';

test('simple test', () => {
const {stdout} = runTest(`
const {stdout} = testUtils(`
describe('describe', () => {
beforeEach(() => {});
afterEach(() => {});
Expand All @@ -26,7 +26,7 @@ test('simple test', () => {
});

test('failures', () => {
const {stdout} = runTest(`
const {stdout} = testUtils(`
describe('describe', () => {
beforeEach(() => {});
afterEach(() => { throw new Error('banana')});
Expand Down
8 changes: 4 additions & 4 deletions packages/jest-circus/src/__tests__/hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

'use strict';

import {runTest} from '../__mocks__/test_utils';
import {testUtils} from '../__mocks__/testUtils';

test('beforeEach is executed before each test in current/child describe blocks', () => {
const {stdout} = runTest(`
const {stdout} = testUtils(`
describe('describe', () => {
beforeEach(() => console.log('> describe beforeEach'));
test('one', () => {});
Expand Down Expand Up @@ -42,7 +42,7 @@ test('beforeEach is executed before each test in current/child describe blocks',
});

test('multiple before each hooks in one describe are executed in the right order', () => {
const {stdout} = runTest(`
const {stdout} = testUtils(`
describe('describe 1', () => {
beforeEach(() => {
console.log('before each 1');
Expand All @@ -61,7 +61,7 @@ test('multiple before each hooks in one describe are executed in the right order
});

test('beforeAll is exectued correctly', () => {
const {stdout} = runTest(`
const {stdout} = testUtils(`
describe('describe 1', () => {
beforeAll(() => console.log('> beforeAll 1'));
test('test 1', () => console.log('> test 1'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import {
import {
injectGlobalErrorHandlers,
restoreGlobalErrorHandlers,
} from './error_handlers';
} from './globalErrorHandlers';

// To pass this value from Runtime object to state we need to use global[sym]
const TEST_TIMEOUT_SYMBOL = Symbol.for('TEST_TIMEOUT_SYMBOL');

const handler: EventHandler = (event, state): void => {
const eventHandler: EventHandler = (event, state): void => {
switch (event.name) {
case 'include_test_location_in_result': {
state.includeTestLocationInResult = true;
Expand Down Expand Up @@ -183,4 +183,4 @@ const handler: EventHandler = (event, state): void => {
}
};

export default handler;
export default eventHandler;
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const humanReadableOperators = {
strictEqual: 'to strictly be equal',
};

export default (event: Event, state: State) => {
const formatNodeAssertErrors = (event: Event, state: State) => {
switch (event.name) {
case 'test_done': {
event.test.errors = event.test.errors.map(errors => {
Expand Down Expand Up @@ -167,3 +167,5 @@ function assertionErrorMessage(error: AssertionError, options: DiffOptions) {
trimmedStack
);
}

export default formatNodeAssertErrors;
4 changes: 2 additions & 2 deletions packages/jest-circus/src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import type {Event, State, EventHandler} from 'types/Circus';

import {makeDescribe} from './utils';
import eventHandler from './event_handler';
import formatNodeAssertErrors from './format_node_assert_errors';
import eventHandler from './eventHandler';
import formatNodeAssertErrors from './formatNodeAssertErrors';

const eventHandlers: Array<EventHandler> = [
eventHandler,
Expand Down