Skip to content

Commit

Permalink
iterator-to-null test
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov committed Jun 22, 2017
1 parent 8b224cf commit 95c774f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
14 changes: 14 additions & 0 deletions integration_tests/__tests__/iterator-to-null-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* 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';

Array.prototype[Symbol.iterator] = null;
String.prototype[Symbol.iterator] = null;

test('modifying global object does not affect test runner', () => {});
7 changes: 4 additions & 3 deletions packages/jest-jasmine2/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import jasmineAsync from './jasmine-async';

const JASMINE = require.resolve('./jasmine/jasmine-light.js');

function jasmine2(
async function jasmine2(
globalConfig: GlobalConfig,
config: ProjectConfig,
environment: Environment,
Expand All @@ -33,7 +33,7 @@ function jasmine2(
environment,
testPath,
);
const jasmineFactory = runtime.requireInternalModule(JASMINE);
const jasmineFactory = require(JASMINE);
const jasmine = jasmineFactory.create();

const env = jasmine.getEnv();
Expand Down Expand Up @@ -92,8 +92,9 @@ function jasmine2(
env.specFilter = spec => testNameRegex.test(spec.getFullName());
}

runtime.requireModule(require.resolve('p-map'));
runtime.requireModule(testPath);
env.execute();
await env.execute();
return reporter
.getResults()
.then(results => addSnapshotData(results, snapshotState));
Expand Down
17 changes: 8 additions & 9 deletions packages/jest-jasmine2/src/jasmine/Env.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ module.exports = function(j$) {
return seed;
};

function queueRunnerFactory(options) {
async function queueRunnerFactory(options) {
options.clearTimeout = realClearTimeout;
options.fail = self.fail;
options.setTimeout = realSetTimeout;
Expand All @@ -178,7 +178,7 @@ module.exports = function(j$) {
return topSuite;
};

this.execute = function(runnablesToRun) {
this.execute = async function(runnablesToRun) {
if (!runnablesToRun) {
if (focusedRunnables.length) {
runnablesToRun = focusedRunnables;
Expand All @@ -193,7 +193,7 @@ module.exports = function(j$) {

currentlyExecutingSuites.push(topSuite);

treeProcessor({
await treeProcessor({
nodeComplete(suite) {
if (!suite.disabled) {
clearResourcesForRunnable(suite.id);
Expand All @@ -209,12 +209,11 @@ module.exports = function(j$) {
queueRunnerFactory,
runnableIds: runnablesToRun,
tree: topSuite,
}).then(() => {
clearResourcesForRunnable(topSuite.id);
currentlyExecutingSuites.pop();
reporter.jasmineDone({
failedExpectations: topSuite.result.failedExpectations,
});
});
clearResourcesForRunnable(topSuite.id);
currentlyExecutingSuites.pop();
reporter.jasmineDone({
failedExpectations: topSuite.result.failedExpectations,
});
};

Expand Down
4 changes: 2 additions & 2 deletions packages/jest-jasmine2/src/queueRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ type QueueableFn = {
timeout?: () => number,
};

function queueRunner(options: Options) {
async function queueRunner(options: Options) {
const mapper = ({fn, timeout}) => {
const promise = new Promise(resolve => {
const next = () => resolve();
const next = () => resolve();
next.fail = function() {
options.fail.apply(null, arguments);
resolve();
Expand Down

0 comments on commit 95c774f

Please sign in to comment.