Skip to content

Commit

Permalink
{it,test,xit,xtest,context}.{skip,only}
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov committed Sep 7, 2016
1 parent 0d342ee commit 90fe16e
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 9 deletions.
22 changes: 22 additions & 0 deletions integration_tests/__tests__/__snapshots__/globals-test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
exports[`test global jest variables 1`] = `
" PASS __tests__/globals-test.js
✓ it.only
✓ test.only
○ it
○ test
○ it.skip
○ test.skip
○ xit
○ xtest
describe.only
✓ test
context.only
✓ test
describe
○ test
context
○ test
Test Summary
› Ran all tests."
`;
23 changes: 14 additions & 9 deletions integration_tests/__tests__/globals-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails oncall+jsinfra
*/

'use strict';

describe('Common globals', () => {
it('check process', () => {
if (Symbol && Symbol.toStringTag) {
expect(Object.prototype.toString.call(global.process))
.toBe('[object process]');
}
});
const path = require('path');
const runJest = require('../runJest');

const dir = path.resolve(__dirname, '../globals');

test('global jest variables', () => {
let {stderr} = runJest(dir);
stderr = stderr
.split('\n')
.slice(0, -2)
.join('\n')
.replace(/\s*\(.*ms\)/gm, '');
expect(stderr).toMatchSnapshot();
});
46 changes: 46 additions & 0 deletions integration_tests/globals/__tests__/globals-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

'use strict';

/* eslint-disable no-undef */

it('it', () => {});
test('test', () => {});

describe('describe', () => {
test('test', () => {});
});

context('context', () => {
test('test', () => {});
});

describe.only('describe.only', () => {
test('test', () => {});
});

context.only('context.only', () => {
test('test', () => {});
});

it.skip('it.skip', () => {});
test.skip('test.skip', () => {});

it.only('it.only', () => {});
test.only('test.only', () => {});

xit('xit', () => {});
xtest('xtest', () => {});
xdescribe('xdescribe', () => {
test('test');
});

xcontext('xcontext', () => {
test('test');
});
1 change: 1 addition & 0 deletions integration_tests/globals/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
19 changes: 19 additions & 0 deletions packages/jest-cli/src/__tests__/globals-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails oncall+jsinfra
*/
'use strict';

describe('Common globals', () => {
it('check process', () => {
if (Symbol && Symbol.toStringTag) {
expect(Object.prototype.toString.call(global.process))
.toBe('[object process]');
}
});
});
12 changes: 12 additions & 0 deletions packages/jest-jasmine2/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,19 @@ function jasmine2(
env.addReporter(jasmineInterface.jsApiReporter);

jasmineAsync.install(environment.global);

environment.global.test = environment.global.it;
environment.global.it.only = environment.global.fit;
environment.global.test.only = environment.global.fit;
environment.global.it.skip = environment.global.xit;
environment.global.test.skip = environment.global.xit;
environment.global.xtest = environment.global.xit;
environment.global.context = environment.global.describe;
environment.global.xcontext = environment.global.xdescribe;
environment.global.context.skip = environment.global.xdescribe;
environment.global.describe.skip = environment.global.xdescribe;
environment.global.describe.only = environment.global.fdescribe;


if (config.setupTestFrameworkScriptFile) {
runtime.requireModule(config.setupTestFrameworkScriptFile);
Expand Down

0 comments on commit 90fe16e

Please sign in to comment.