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

Add extraGlobals option #7454

Merged
merged 3 commits into from
Dec 24, 2018
Merged

Conversation

corevo
Copy link
Contributor

@corevo corevo commented Dec 3, 2018

Summary

This diffs aims to give the user a workaround for expensive vm property lookups.
As explained here, lookups for undefined properties inside the vm context are expensive, as node will go and try to look them up in the sandbox and then further up in the global context, each of those is very expensive.
I have tests that constantly make calls to Math, and these lookups render them horrendously slow, the problem fixing the issue, is that theres plenty of different variables, unknown to jest which ones will be needed, and in fact, this is a node problem.
But still we gotta let the users have a way to get tests to be fast.

The idea is to allow users define these variables through an optional method in the Environment, for the case of #5163 it would be like so:

const NodeEnvironment = require('jest-environment-node');

class MathEnvironment extends NodeEnvironment {
  constructor(config) {
    super(config);
  }

  async setup() {
    await super.setup();
  }

  async teardown() {
    await super.teardown();
  }

  transformScript(script) {
    return '((Math)=> {\n' + script + '\n })(Math);';
  }

  runScript(script) {
    return super.runScript(script);
  }
}

module.exports = MathEnvironment;

Fixes #5163

Test plan

I ran yarn test, seems to fail due to unrelated unstable changes in master.
Also wanna know what's the best way to test this change, and wether this change should be reflected here.

yarn run v1.12.3
$ yarn typecheck && yarn lint && yarn jest
$ flow check --include-warnings
Found 0 errors
$ eslint . --cache --ext js,md
$ node ./packages/jest-cli/bin/jest.js
 PASS  packages/jest-runtime/src/__tests__/Runtime-sourceMaps.test.js
 PASS  packages/jest-runtime/src/__tests__/resolve_browser.test.js
 PASS  packages/jest-runtime/src/__tests__/runtime_gen_mock_from_module.test.js
 PASS  packages/jest-runtime/src/__tests__/runtime_require_module_or_mock.test.js
 PASS  packages/jest-runtime/src/__tests__/runtime_module_directories.test.js
 PASS  packages/jest-runtime/src/__tests__/runtime_require_module.test.js (5.294s)
 PASS  packages/jest-runtime/src/__tests__/runtime_environment.test.js
 PASS  packages/jest-runtime/src/__tests__/runtime_require_mock.test.js
 PASS  packages/jest-runtime/src/__tests__/runtime_require_module_or_mock_transitive_deps.test.js (5.669s)
 PASS  packages/jest-runtime/src/__tests__/runtime_node_path.test.js
 PASS  packages/jest-runtime/src/__tests__/runtime_mock.test.js
 PASS  packages/jest-runtime/src/__tests__/runtime_require_module_no_ext.test.js
 PASS  packages/jest-runtime/src/__tests__/runtime_jest_spy_on.test.js
 PASS  packages/jest-runtime/src/__tests__/runtime_internal_module.test.js
 PASS  packages/jest-runtime/src/__tests__/instrumentation.test.js
 PASS  packages/jest-runtime/src/__tests__/runtime_jest_fn.js
 PASS  packages/jest-runtime/src/__tests__/script_transformer.test.js (7.8s)
 PASS  packages/jest-mock/src/__tests__/jest_mock.test.js
 PASS  packages/pretty-format/src/__tests__/Immutable.test.js
 PASS  packages/jest-util/src/__tests__/fakeTimers.test.js
 PASS  packages/diff-sequences/src/__tests__/index.test.js
 PASS  packages/jest-config/src/__tests__/normalize.test.js
 PASS  packages/jest-haste-map/src/__tests__/index.test.js (5.296s)
 PASS  packages/pretty-format/src/__tests__/prettyFormat.test.js
 PASS  packages/pretty-format/src/__tests__/react.test.js
  ● Console

    console.error packages/pretty-format/node_modules/react/cjs/react.development.js:241
      Warning: forwardRef render functions accept exactly two parameters: props and ref. Did you forget to use the ref parameter?

 PASS  packages/jest-diff/src/__tests__/diff.test.js
 PASS  packages/jest-haste-map/src/crawlers/__tests__/watchman.test.js
 PASS  packages/expect/src/__tests__/spyMatchers.test.js (5.082s)
 PASS  packages/expect/src/__tests__/matchers.test.js (6.147s)
 PASS  packages/jest-docblock/src/__tests__/index.test.js
 PASS  packages/jest-each/src/__tests__/template.test.js
 PASS  packages/jest-each/src/__tests__/array.test.js
 PASS  packages/pretty-format/src/__tests__/DOMElement.test.js
 PASS  packages/jest-cli/src/__tests__/SnapshotInteractiveMode.test.js
 PASS  packages/jest-cli/src/reporters/__tests__/verbose_reporter.test.js
 PASS  packages/jest-cli/src/__tests__/SearchSource.test.js
 FAIL  packages/jest-cli/src/__tests__/watch.test.js (5.166s)
  ● Watch mode flows › Runs Jest once by default and shows usage

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows Runs Jest once by default and shows usage 1".

    - Snapshot
    + Received

      Array [
        "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    +  › Press q to quit watch mode.
    +  › Press t to filter by a test name regex pattern.
       › Press p to filter by a filename regex pattern.
    -  › Press t to filter by a test name regex pattern.
    -  › Press q to quit watch mode.
       › Press Enter to trigger a test run.
      ",
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:159:48)

  ● Watch mode flows › shows prompts for WatchPlugins in alphabetical order

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows shows prompts for WatchPlugins in alphabetical order 1".

    - Snapshot
    + Received

    @@ -2,14 +2,14 @@
        Array [
          "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    -  › Press p to filter by a filename regex pattern.
    -  › Press t to filter by a test name regex pattern.
       › Press q to quit watch mode.
       › Press r to do something else.
       › Press s to do nothing.
    +  › Press t to filter by a test name regex pattern.
    +  › Press p to filter by a filename regex pattern.
       › Press Enter to trigger a test run.
      ",
        ],
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:220:60)

  ● Watch mode flows › shows update snapshot prompt (without interactive)

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows shows update snapshot prompt (without interactive) 1".

    - Snapshot
    + Received

    @@ -2,13 +2,13 @@
        Array [
          "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    +  › Press q to quit watch mode.
    +  › Press u to update failing snapshots.
    +  › Press t to filter by a test name regex pattern.
       › Press p to filter by a filename regex pattern.
    -  › Press t to filter by a test name regex pattern.
    -  › Press u to update failing snapshots.
    -  › Press q to quit watch mode.
       › Press Enter to trigger a test run.
      ",
        ],
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:247:60)

  ● Watch mode flows › shows update snapshot prompt (with interactive)

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows shows update snapshot prompt (with interactive) 1".

    - Snapshot
    + Received

    @@ -2,14 +2,14 @@
        Array [
          "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    +  › Press q to quit watch mode.
    +  › Press i to update failing snapshots interactively.
    +  › Press u to update failing snapshots.
    +  › Press t to filter by a test name regex pattern.
       › Press p to filter by a filename regex pattern.
    -  › Press t to filter by a test name regex pattern.
    -  › Press u to update failing snapshots.
    -  › Press i to update failing snapshots interactively.
    -  › Press q to quit watch mode.
       › Press Enter to trigger a test run.
      ",
        ],
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:293:60)

  ● Watch mode flows › allows WatchPlugins to override eligible internal plugins

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows allows WatchPlugins to override eligible internal plugins 1".

    - Snapshot
    + Received

      Array [
        "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    +  › Press p to custom "P" plugin.
    +  › Press q to quit watch mode.
       › Press t to filter by a test name regex pattern.
    -  › Press q to quit watch mode.
    -  › Press p to custom "P" plugin.
       › Press Enter to trigger a test run.
      ",
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:359:48)

  ● Watch mode flows › allows WatchPlugins to be configured

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows allows WatchPlugins to be configured 1".

    - Snapshot
    + Received

      Array [
        "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    +  › Press k to filter with a custom prompt.
    +  › Press q to quit watch mode.
    +  › Press t to filter by a test name regex pattern.
       › Press p to filter by a filename regex pattern.
    -  › Press t to filter by a test name regex pattern.
    -  › Press q to quit watch mode.
    -  › Press k to filter with a custom prompt.
       › Press Enter to trigger a test run.
      ",
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:537:48)

 › 6 snapshots failed.
 PASS  packages/jest-worker/src/__tests__/index.test.js
 PASS  packages/jest-worker/src/__tests__/Worker.test.js
 PASS  packages/jest-cli/src/reporters/__tests__/coverage_reporter.test.js
 PASS  packages/jest-worker/src/__tests__/child.test.js
 PASS  packages/expect/src/__tests__/asymmetricMatchers.test.js
 PASS  packages/jest-resolve/src/__tests__/resolve.test.js
 PASS  packages/pretty-format/src/__tests__/AsymmetricMatcher.test.js
 PASS  packages/expect/src/__tests__/toThrowMatchers.test.js
 PASS  packages/jest-haste-map/src/lib/__tests__/dependencyExtractor.test.js
 PASS  packages/jest-cli/src/lib/__tests__/init.test.js
 PASS  packages/jest-snapshot/src/__tests__/utils.test.js
 FAIL  packages/jest-cli/src/__tests__/test_sequencer.test.js
  ● sorts based on failures, timing information and file size

    expect(received).toEqual(expected)

    Expected value to equal:
      [{"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": undefined, "path": "/test-efg.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": undefined, "path": "/test-c.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 1, "path": "/test-ab.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 5, "path": "/test-a.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 2, "path": "/test-d.js"}]
    Received:
      [{"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 1, "path": "/test-ab.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": undefined, "path": "/test-efg.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": undefined, "path": "/test-c.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 5, "path": "/test-a.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 2, "path": "/test-d.js"}]

    Difference:

    - Expected
    + Received

    @@ -5,34 +5,34 @@
              "cache": true,
              "cacheDirectory": "/cache",
              "name": "test",
            },
          },
    -     "duration": undefined,
    -     "path": "/test-efg.js",
    +     "duration": 1,
    +     "path": "/test-ab.js",
        },
        Object {
          "context": Object {
            "config": Object {
              "cache": true,
              "cacheDirectory": "/cache",
              "name": "test",
            },
          },
          "duration": undefined,
    -     "path": "/test-c.js",
    +     "path": "/test-efg.js",
        },
        Object {
          "context": Object {
            "config": Object {
              "cache": true,
              "cacheDirectory": "/cache",
              "name": "test",
            },
          },
    -     "duration": 1,
    -     "path": "/test-ab.js",
    +     "duration": undefined,
    +     "path": "/test-c.js",
        },
        Object {
          "context": Object {
            "config": Object {
              "cache": true,

      at Object.toEqual (packages/jest-cli/src/__tests__/test_sequencer.test.js:113:5)

 PASS  packages/jest-validate/src/__tests__/validate.test.js
 PASS  packages/jest-util/src/__tests__/deepCyclicCopy.test.js
 PASS  packages/jest-haste-map/src/crawlers/__tests__/node.test.js
 PASS  e2e/__tests__/jest_changed_files.test.js (36.317s)
 PASS  packages/jest-snapshot/src/__tests__/inline_snapshots.test.js
 PASS  packages/jest-haste-map/src/__tests__/worker.test.js
 PASS  packages/jest-runtime/src/__tests__/should_instrument.test.js
 PASS  e2e/__tests__/globals.test.js (38.533s)
 PASS  e2e/__tests__/multi_project_runner.test.js (76.672s)
 PASS  e2e/__tests__/snapshot.test.js (76.677s)
 PASS  packages/jest-cli/src/__tests__/notify_reporter.test.js (5.128s)
 PASS  e2e/__tests__/to_match_inline_snapshot.test.js (82.56s)
 PASS  e2e/__tests__/coverage_threshold.test.js (48.983s)
 PASS  e2e/__tests__/find_related_files.test.js (36.78s)
 PASS  packages/jest-message-util/src/__tests__/messages.test.js
 PASS  packages/jest-snapshot/src/__tests__/mock_serializer.test.js
 PASS  packages/jest-cli/src/__tests__/watch_filename_pattern_mode.test.js
 PASS  packages/pretty-format/src/__tests__/DOMCollection.test.js
 PASS  packages/jest-jasmine2/src/__tests__/queueRunner.test.js
 PASS  packages/jest-cli/src/__tests__/watch_test_name_pattern_mode.test.js
 PASS  packages/expect/src/__tests__/extend.test.js
 PASS  packages/expect/src/__tests__/utils.test.js
 PASS  packages/jest-util/src/__tests__/console.test.js
 PASS  packages/jest-worker/src/__tests__/index-integration.test.js
 PASS  packages/jest-util/src/__tests__/bufferedConsole.test.js
 PASS  e2e/__tests__/to_match_snapshot.test.js (113.404s)
 PASS  packages/jest-cli/src/reporters/__tests__/summary_reporter.test.js
 PASS  e2e/__tests__/only_changed.test.js (118.591s)
 PASS  e2e/__tests__/failures.test.js (50.334s)
 PASS  e2e/__tests__/json_reporter.test.js (9.833s)
 PASS  e2e/__tests__/custom_reporters.test.js (42.343s)
 PASS  packages/jest-matcher-utils/src/__tests__/index.test.js
 PASS  packages/jest-resolve-dependencies/src/__tests__/dependency_resolver.test.js
 PASS  packages/jest-cli/src/reporters/__tests__/utils.test.js
 PASS  packages/jest-util/src/__tests__/createProcessObject.test.js
 PASS  e2e/__tests__/stack_trace.test.js (30.202s)
 PASS  e2e/__tests__/jasmine_async.test.js (59.008s)
 PASS  e2e/__tests__/to_throw_error_matching_snapshot.test.js (25.324s)
 PASS  packages/jest-snapshot/src/__tests__/snapshot_resolver.test.js

 RUNS  packages/jest-cli/src/__tests__/TestScheduler.test.js
 RUNS  e2e/__tests__/coverage_report.test.js
 RUNS  packages/jest-leak-detector/src/__tests__/index.test.js
 RUNS  e2e/__tests__/to_throw_error_matching_inline_snapshot.test.js
 RUNS  packages/jest-runner/src/__tests__/test_runner.test.js
 RUNS  e2e/__tests__/dependency_clash.test.js
 RUNS  e2e/__tests__/transform.test.js

Test Suites: 2 failed, 86 passed, 88 of 297 total
 PASS  packages/jest-cli/src/__tests__/TestScheduler.test.js
 PASS  packages/jest-runner/src/__tests__/test_runner.test.js
 PASS  packages/jest-config/src/__tests__/resolveConfigPath.test.js
 PASS  packages/jest-watcher/src/lib/__tests__/formatTestNameByPattern.test.js
 PASS  packages/jest-circus/src/__tests__/circusItTestError.test.js
 PASS  packages/jest-leak-detector/src/__tests__/index.test.js (5.069s)
 PASS  packages/jest-cli/src/reporters/__tests__/get_snapshot_summary.test.js
 PASS  packages/jest-cli/src/__tests__/runJestWithCoverage.test.js
 PASS  e2e/__tests__/test_retries.test.js
  ● Console

    console.warn scripts/ConditionalTest.js:19
      [SKIP] Does not work on Jasmine

 PASS  packages/jest-serializer/src/__tests__/index.test.js
 PASS  packages/jest-jasmine2/src/__tests__/iterators.test.js
 PASS  e2e/__tests__/dependency_clash.test.js (7.662s)
 PASS  packages/jest-cli/src/lib/__tests__/is_valid_path.test.js
 PASS  e2e/__tests__/transform.test.js (62.633s)
 PASS  e2e/__tests__/haste_map_sha1.test.js
 PASS  e2e/__tests__/to_throw_error_matching_inline_snapshot.test.js (24.673s)
 PASS  e2e/__tests__/unexpected-token.test.js (15.995s)
 PASS  packages/jest-cli/src/reporters/__tests__/default_reporter.test.js
 PASS  packages/jest-jasmine2/src/__tests__/expectationResultFactory.test.js
 PASS  packages/jest-util/src/__tests__/getCallsite.test.js
 PASS  e2e/__tests__/watch_mode_patterns.test.js (18.607s)
 PASS  e2e/__tests__/jest.config.js.test.js (16.631s)
 PASS  packages/jest-cli/src/__tests__/cli/args.test.js
 PASS  packages/jest-haste-map/src/lib/__tests__/fast_path.test.js
 PASS  e2e/__tests__/timeouts_legacy.test.js (23.327s)
 PASS  packages/jest-circus/src/__tests__/hooks.test.js (13.239s)
 PASS  e2e/__tests__/detect_open_handles.js (27.225s)
 PASS  packages/jest-circus/src/__tests__/afterAll.test.js (12.416s)
 PASS  packages/jest-regex-util/src/__tests__/index.test.js
 PASS  e2e/__tests__/execute-tests-once-in-mpr.js (8.843s)
 PASS  e2e/__tests__/global_teardown.test.js (17.187s)
 PASS  e2e/__tests__/location_in_results.test.js (11.04s)
 PASS  packages/jest-util/src/__tests__/isInteractive.test.js
 PASS  examples/async/__tests__/user.test.js
 PASS  e2e/__tests__/coverage_report.test.js (119.56s)
 PASS  e2e/__tests__/no_tests_found.test.js (11.123s)
 PASS  e2e/__tests__/setup_files_after_env_config.test.js (16.401s)
 PASS  packages/jest-jasmine2/src/__tests__/itTestError.test.js
 PASS  packages/jest-cli/src/__tests__/FailedTestsCache.test.js
 PASS  e2e/__tests__/each.test.js (36.723s)
 PASS  e2e/__tests__/global_setup.test.js (12.311s)
 PASS  e2e/__tests__/mock_names.test.js (44.277s)
 PASS  e2e/__tests__/watch_mode_update_snapshot.test.js (9.633s)
 PASS  packages/jest-config/src/__tests__/setFromArgv.test.js
 PASS  e2e/__tests__/console.test.js (23.528s)
 PASS  packages/jest-watcher/src/lib/__tests__/prompt.test.js
 PASS  e2e/__tests__/config.test.js (23.052s)
 PASS  packages/pretty-format/src/__tests__/ConvertAnsi.test.js
 PASS  packages/expect/src/__tests__/stacktrace.test.js
 PASS  packages/jest-jasmine2/src/__tests__/pTimeout.test.js
 PASS  packages/jest-util/src/__tests__/getFailedSnapshot.test.js
 PASS  e2e/__tests__/watch_mode_only_failed.test.js (8.85s)
 PASS  e2e/__tests__/cli-handles-exact-filenames.test.js (5.656s)
 PASS  packages/jest-runtime/src/__tests__/runtime_cli.test.js (22.057s)
 PASS  packages/expect/src/__tests__/isError.test.js
 PASS  packages/jest-cli/src/reporters/__tests__/coverage_worker.test.js
 PASS  packages/jest-snapshot/src/__tests__/throw_matcher.test.js
 PASS  packages/jest-watcher/src/lib/__tests__/scroll.test.js
 PASS  e2e/__tests__/timeouts.test.js (13.492s)
 PASS  examples/react-native/__tests__/intro.test.js (37.359s)
 PASS  examples/timer/__tests__/timer_game.test.js
  ● Console

    console.log examples/timer/timerGame.js:4
      Ready....go!
    console.log examples/timer/timerGame.js:4
      Ready....go!
    console.log examples/timer/timerGame.js:6
      Times up -- stop!
    console.log examples/timer/timerGame.js:6
      Times up -- stop!
    console.log examples/timer/timerGame.js:4
      Ready....go!
    console.log examples/timer/timerGame.js:6
      Times up -- stop!

 PASS  e2e/__tests__/show_config.test.js
 PASS  e2e/__tests__/empty-describe-with-hooks.test.js
  ● Console

    console.warn scripts/ConditionalTest.js:19
      [SKIP] Does not work on Jasmine

 PASS  e2e/__tests__/jest_require_actual.test.js (12.356s)
 PASS  packages/jest-cli/src/reporters/__tests__/get_snapshot_status.test.js
 PASS  e2e/__tests__/jest_require_mock.test.js (12.428s)
 PASS  examples/jquery/__tests__/fetch_current_user.test.js
 PASS  packages/jest-environment-node/src/__tests__/node_environment.test.js
 PASS  e2e/__tests__/run_tests_by_path.test.js (10.255s)
 PASS  e2e/__tests__/snapshot_serializers.test.js (10.764s)
 PASS  e2e/__tests__/force_exit.test.js (9.302s)
 PASS  examples/snapshot/__tests__/link.react.test.js
 PASS  e2e/__tests__/resolve_no_file_extensions.test.js (8.799s)
 PASS  examples/module-mock/__tests__/mock_per_test.js
 PASS  e2e/__tests__/list_tests.test.js (5.209s)
 PASS  packages/jest-cli/src/lib/__tests__/modify_package_json.test.js
 PASS  packages/jest-jasmine2/src/__tests__/reporter.test.js
 PASS  e2e/__tests__/test-todo.test.js (20.643s)
 PASS  packages/babel-jest/src/__tests__/index.js
 PASS  packages/jest-circus/src/__tests__/circusItTodoTestError.test.js
 PASS  e2e/__tests__/coverage_remapping.test.js (12.074s)
 PASS  e2e/__tests__/coverage_transform_instrumented.test.js (19.304s)
 PASS  packages/expect/src/__tests__/symbolInObjects.test.js
 PASS  packages/jest-cli/src/lib/__tests__/log_debug_messages.test.js
 PASS  e2e/__tests__/runtime_internal_module_registry.test.js (5.184s)
 PASS  packages/jest-get-type/src/__tests__/index.test.js
 PASS  e2e/__tests__/filter.test.js (26.02s)
 PASS  packages/jest-cli/src/__tests__/generateEmptyCoverage.test.js
 PASS  packages/expect/src/__tests__/assertionCounts.test.js
 PASS  e2e/__tests__/snapshot_resolver.test.js
 PASS  examples/jquery/__tests__/display_user.test.js
 PASS  packages/jest-util/src/__tests__/installCommonGlobals.test.js
 PASS  packages/jest-validate/src/__tests__/validateCLIOptions.test.js
 PASS  e2e/__tests__/use_stderr.test.js (7.02s)
 PASS  packages/jest-cli/src/__tests__/run_jest.test.js
 PASS  e2e/__tests__/clear_cache.test.js (6.695s)
 PASS  e2e/__tests__/test_failure_exit_code.test.js (12.568s)
 PASS  packages/jest-config/src/__tests__/getMaxWorkers.test.js
 PASS  examples/module-mock/__tests__/partial_mock.js
 PASS  examples/timer/__tests__/infinite_timer_game.test.js
  ● Console

    console.log examples/timer/infiniteTimerGame.js:4
      Ready....go!
    console.log examples/timer/infiniteTimerGame.js:7
      Times up! 10 seconds before the next game starts...

 PASS  packages/jest-circus/src/__tests__/baseTest.test.js
 PASS  e2e/__tests__/version.test.js
 PASS  packages/jest-util/src/__tests__/formatTestResults.test.js
 PASS  packages/jest-config/src/__tests__/validatePattern.test.js
 PASS  e2e/__tests__/console_log_output_when_run_in_band.test.js (6.455s)
 PASS  packages/jest-haste-map/src/lib/__tests__/getPlatformExtension.test.js
 PASS  packages/jest-haste-map/src/lib/__tests__/normalizePathSep.test.js
 PASS  examples/react/__tests__/CheckboxWithLabel-test.js
 PASS  e2e/__tests__/no_test_found.test.js
 PASS  packages/jest-jasmine2/src/__tests__/todoError.test.js
 PASS  packages/jest-circus/src/__tests__/hooksError.test.js
 PASS  e2e/__tests__/env.test.js (16.047s)
 PASS  e2e/__tests__/log_heap_usage.test.js
 PASS  examples/typescript/__tests__/CheckboxWithLabel-test.tsx
 PASS  packages/jest-each/src/__tests__/index.test.js
 PASS  e2e/__tests__/expect-async-matcher.test.js (10.068s)
 PASS  packages/jest-jasmine2/src/__tests__/hooksError.test.js
 PASS  e2e/__tests__/test_path_pattern_reporter_message.test.js (30.819s)
 PASS  e2e/__tests__/jasmine_async_with_pending_during_test.js (5.273s)
 PASS  e2e/__tests__/deprecated_cli_options.test.js (8.113s)
 PASS  e2e/__tests__/native_async_mock.test.js
 PASS  packages/jest-util/src/__tests__/errorWithStack.test.js
 PASS  e2e/__tests__/promise_reject.test.js (8.88s)
 PASS  e2e/__tests__/resolve-with-paths.test.js (5.797s)
 PASS  packages/jest-repl/src/__tests__/jest_repl.test.js (7.505s)
 PASS  packages/jest-snapshot/src/__tests__/matcher.test.js
 PASS  e2e/__tests__/module_name_mapper.test.js (17.217s)
 PASS  packages/jest-environment-jsdom/src/__tests__/jsdom_environment.test.js
 PASS  e2e/__tests__/test_in_root.test.js (8.484s)
 PASS  examples/manual-mocks/__tests__/file_summarizer.test.js
 PASS  packages/jest-resolve/src/__tests__/isBuiltinModule.test.js
 PASS  e2e/__tests__/test_environment_async.test.js (8.742s)
 PASS  e2e/__tests__/override-globals.test.js (11.154s)
 PASS  e2e/__tests__/stack_trace_source_maps.test.js (10.266s)
 PASS  examples/enzyme/__tests__/CheckboxWithLabel-test.js
 PASS  e2e/__tests__/debug.test.js
 PASS  examples/react-testing-library/__tests__/CheckboxWithLabel-test.js
 PASS  e2e/__tests__/require_after_teardown.test.js
 PASS  e2e/__tests__/empty_suite_error.test.js
 PASS  packages/jest-haste-map/src/lib/__tests__/isRegExpSupported.test.js
 PASS  e2e/__tests__/test_results_processor.test.js
 PASS  e2e/__tests__/fake-promises.test.js (9.524s)
 PASS  e2e/__tests__/custom_matcher_stack_trace.test.js
 PASS  packages/jest-haste-map/src/__tests__/get_mock_name.test.js
 PASS  e2e/__tests__/test_environment.test.js (7.591s)
 PASS  e2e/__tests__/test_name_pattern_skipped.test.js (5.406s)
 PASS  e2e/__tests__/babel_plugin_jest_hoist.test.js (15.602s)
 PASS  e2e/timer-reset-mocks/after-reset-all-mocks/timer_and_mock.test.js
 PASS  packages/jest-jasmine2/src/__tests__/Suite.test.js
 PASS  examples/automatic-mocks/__tests__/genMockFromModule.test.js
 PASS  e2e/__tests__/typescript_coverage.test.js (8.866s)
 PASS  e2e/__tests__/test_name_pattern.test.js (5.96s)
 PASS  e2e/__tests__/timer_reset_mocks.test.js (10.109s)
 PASS  e2e/__tests__/regex_(char_in_path.test.js
 PASS  e2e/__tests__/stack_trace_no_captureStackTrace.test.js
 PASS  e2e/__tests__/auto_restore_mocks.test.js (9.929s)
 PASS  e2e/__tests__/verbose.test.js
 PASS  e2e/__tests__/auto_reset_mocks.test.js (9.117s)
 PASS  e2e/__tests__/auto_clear_mocks.test.js (9.255s)
 PASS  e2e/__tests__/require_main.test.js
 PASS  packages/expect/src/__tests__/fakeChalk.test.js
 PASS  e2e/__tests__/timer_use_real_timers.test.js
 PASS  examples/automatic-mocks/__tests__/automock.test.js
 PASS  e2e/__tests__/transform-linked-modules.test.js
 PASS  e2e/__tests__/error-on-deprecated.test.js (113.86s)
 PASS  e2e/__tests__/node_path.test.js (5.288s)
 PASS  e2e/__tests__/before-all-filtered.js (7.51s)
 PASS  e2e/__tests__/json.test.js
 PASS  packages/jest-cli/src/__tests__/globals.test.js
 PASS  e2e/__tests__/before-each-queue.js (7.417s)
 PASS  packages/jest-config/src/__tests__/readConfig.test.js
 PASS  e2e/__tests__/compare_dom_nodes.test.js (8.28s)
 PASS  e2e/__tests__/lifecycles.js (6.465s)
 PASS  e2e/__tests__/set_immediate.test.js (6.721s)
 PASS  e2e/__tests__/reset_modules.test.js (6.895s)
 PASS  e2e/__tests__/bad_source_map.test.js (6.832s)
 PASS  examples/snapshot/__tests__/clock.react.test.js
 PASS  e2e/__tests__/process_exit.test.js (7.014s)
 PASS  e2e/__tests__/expect_in_vm.test.js (6.568s)
 PASS  e2e/__tests__/presets.test.js (17.255s)
 PASS  e2e/__tests__/generator_mock.test.js (5.588s)
 PASS  e2e/__tests__/resolve-node-module.test.js (5.986s)
 PASS  packages/jest-jasmine2/src/__tests__/matchers.test.js
 PASS  e2e/__tests__/require_v8_module.test.js
 PASS  e2e/__tests__/module_parent_null_in_test.js (8.561s)
 PASS  e2e/__tests__/symbol.test.js
 PASS  packages/jest-config/src/__tests__/readConfigs.test.js
 PASS  e2e/__tests__/nested_event_loop.test.js (8.383s)
 PASS  e2e/__tests__/global.test.js
 PASS  e2e/timer-reset-mocks/with-reset-mocks/timer_with_mock.test.js
 PASS  examples/module-mock/__tests__/full_mock.js
 PASS  e2e/__tests__/resolve-get-paths.test.js (5.023s)
 PASS  e2e/test-in-root/spec.js
 PASS  e2e/test-in-root/test.js
 PASS  packages/jest-jasmine2/src/__tests__/itToTestAlias.test.js
 PASS  examples/manual-mocks/__tests__/user.test.js
 PASS  e2e/__tests__/custom-resolver.test.js (8.342s)
 PASS  examples/automatic-mocks/__tests__/disableAutomocking.test.js
 PASS  packages/jest-config/src/__tests__/Defaults.test.js
 PASS  examples/manual-mocks/__tests__/userMocked.test.js
 PASS  e2e/__tests__/resolve.test.js (6.555s)
 PASS  e2e/global-teardown/custom_tests_dir/pass.test.js
 PASS  examples/manual-mocks/__tests__/lodashMocking.test.js
 PASS  examples/babel-7/__tests__/index.test.js
 PASS  examples/getting-started/sum.test.js
 PASS  e2e/global-setup/custom_tests_dir/pass.test.js
 PASS  examples/typescript/__tests__/sum-test.ts
 PASS  examples/typescript/__tests__/sum.test.js
 PASS  examples/typescript/__tests__/sub-test.ts

Summary of all failing tests
 FAIL  packages/jest-cli/src/__tests__/watch.test.js (5.166s)
  ● Watch mode flows › Runs Jest once by default and shows usage

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows Runs Jest once by default and shows usage 1".

    - Snapshot
    + Received

      Array [
        "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    +  › Press q to quit watch mode.
    +  › Press t to filter by a test name regex pattern.
       › Press p to filter by a filename regex pattern.
    -  › Press t to filter by a test name regex pattern.
    -  › Press q to quit watch mode.
       › Press Enter to trigger a test run.
      ",
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:159:48)

  ● Watch mode flows › shows prompts for WatchPlugins in alphabetical order

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows shows prompts for WatchPlugins in alphabetical order 1".

    - Snapshot
    + Received

    @@ -2,14 +2,14 @@
        Array [
          "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    -  › Press p to filter by a filename regex pattern.
    -  › Press t to filter by a test name regex pattern.
       › Press q to quit watch mode.
       › Press r to do something else.
       › Press s to do nothing.
    +  › Press t to filter by a test name regex pattern.
    +  › Press p to filter by a filename regex pattern.
       › Press Enter to trigger a test run.
      ",
        ],
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:220:60)

  ● Watch mode flows › shows update snapshot prompt (without interactive)

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows shows update snapshot prompt (without interactive) 1".

    - Snapshot
    + Received

    @@ -2,13 +2,13 @@
        Array [
          "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    +  › Press q to quit watch mode.
    +  › Press u to update failing snapshots.
    +  › Press t to filter by a test name regex pattern.
       › Press p to filter by a filename regex pattern.
    -  › Press t to filter by a test name regex pattern.
    -  › Press u to update failing snapshots.
    -  › Press q to quit watch mode.
       › Press Enter to trigger a test run.
      ",
        ],
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:247:60)

  ● Watch mode flows › shows update snapshot prompt (with interactive)

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows shows update snapshot prompt (with interactive) 1".

    - Snapshot
    + Received

    @@ -2,14 +2,14 @@
        Array [
          "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    +  › Press q to quit watch mode.
    +  › Press i to update failing snapshots interactively.
    +  › Press u to update failing snapshots.
    +  › Press t to filter by a test name regex pattern.
       › Press p to filter by a filename regex pattern.
    -  › Press t to filter by a test name regex pattern.
    -  › Press u to update failing snapshots.
    -  › Press i to update failing snapshots interactively.
    -  › Press q to quit watch mode.
       › Press Enter to trigger a test run.
      ",
        ],
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:293:60)

  ● Watch mode flows › allows WatchPlugins to override eligible internal plugins

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows allows WatchPlugins to override eligible internal plugins 1".

    - Snapshot
    + Received

      Array [
        "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    +  › Press p to custom "P" plugin.
    +  › Press q to quit watch mode.
       › Press t to filter by a test name regex pattern.
    -  › Press q to quit watch mode.
    -  › Press p to custom "P" plugin.
       › Press Enter to trigger a test run.
      ",
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:359:48)

  ● Watch mode flows › allows WatchPlugins to be configured

    expect(value).toMatchSnapshot()

    Received value does not match stored snapshot "Watch mode flows allows WatchPlugins to be configured 1".

    - Snapshot
    + Received

      Array [
        "
      Watch Usage
       › Press a to run all tests.
       › Press f to run only failed tests.
    +  › Press k to filter with a custom prompt.
    +  › Press q to quit watch mode.
    +  › Press t to filter by a test name regex pattern.
       › Press p to filter by a filename regex pattern.
    -  › Press t to filter by a test name regex pattern.
    -  › Press q to quit watch mode.
    -  › Press k to filter with a custom prompt.
       › Press Enter to trigger a test run.
      ",
      ]

      at Object.toMatchSnapshot (packages/jest-cli/src/__tests__/watch.test.js:537:48)

 FAIL  packages/jest-cli/src/__tests__/test_sequencer.test.js
  ● sorts based on failures, timing information and file size

    expect(received).toEqual(expected)

    Expected value to equal:
      [{"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": undefined, "path": "/test-efg.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": undefined, "path": "/test-c.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 1, "path": "/test-ab.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 5, "path": "/test-a.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 2, "path": "/test-d.js"}]
    Received:
      [{"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 1, "path": "/test-ab.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": undefined, "path": "/test-efg.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": undefined, "path": "/test-c.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 5, "path": "/test-a.js"}, {"context": {"config": {"cache": true, "cacheDirectory": "/cache", "name": "test"}}, "duration": 2, "path": "/test-d.js"}]

    Difference:

    - Expected
    + Received

    @@ -5,34 +5,34 @@
              "cache": true,
              "cacheDirectory": "/cache",
              "name": "test",
            },
          },
    -     "duration": undefined,
    -     "path": "/test-efg.js",
    +     "duration": 1,
    +     "path": "/test-ab.js",
        },
        Object {
          "context": Object {
            "config": Object {
              "cache": true,
              "cacheDirectory": "/cache",
              "name": "test",
            },
          },
          "duration": undefined,
    -     "path": "/test-c.js",
    +     "path": "/test-efg.js",
        },
        Object {
          "context": Object {
            "config": Object {
              "cache": true,
              "cacheDirectory": "/cache",
              "name": "test",
            },
          },
    -     "duration": 1,
    -     "path": "/test-ab.js",
    +     "duration": undefined,
    +     "path": "/test-c.js",
        },
        Object {
          "context": Object {
            "config": Object {
              "cache": true,

      at Object.toEqual (packages/jest-cli/src/__tests__/test_sequencer.test.js:113:5)


Snapshot Summary
 › 6 snapshots failed from 1 test suite. Inspect your code changes or run `yarn run jest -u` to update them.

Test Suites: 2 failed, 295 passed, 297 total
Tests:       7 failed, 7 skipped, 2989 passed, 3003 total
Snapshots:   6 failed, 1270 passed, 1276 total
Time:        360.95s
Ran all test suites in 15 projects.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@mjesun
Copy link
Contributor

mjesun commented Dec 3, 2018

We should probably make the environment be part of the cache key; otherwise changing the environment via config would make the transform cache return stale results.

@thymikee
Copy link
Collaborator

thymikee commented Dec 3, 2018

I wonder if it makes sense to inject all Node/JS globals like that by default?

@SimenB
Copy link
Member

SimenB commented Dec 3, 2018

How does this work with sourcemaps, and thus stack traces and coverage? If it's an issue, can we use Babel to wrap the code instead (adding it to babel-preset-jest)?

@corevo
Copy link
Contributor Author

corevo commented Dec 3, 2018

@SimenB that's a great point, I'm adding that before the transpilation, which means it would be added to the sourcemaps.
This will probably skew the coverage results, I need to confirm wether this will add an anonymous function to the stack trace.
@thymikee I'm not a node guy, but my intuition is that at the very least the memory gets copied to the vm.

@SimenB
Copy link
Member

SimenB commented Dec 3, 2018

What about something like this (untested) approach?

diff --git i/packages/jest-runtime/src/index.js w/packages/jest-runtime/src/index.js
index f91e481a2..f88d61e2e 100644
--- i/packages/jest-runtime/src/index.js
+++ w/packages/jest-runtime/src/index.js
@@ -617,12 +617,14 @@ class Runtime {
       value: this._createRequireImplementation(localModule, options),
     });
 
+    const extraGlobals = ['Math'];
     const transformedFile = this._scriptTransformer.transform(
       filename,
       {
         collectCoverage: this._coverageOptions.collectCoverage,
         collectCoverageFrom: this._coverageOptions.collectCoverageFrom,
         collectCoverageOnlyFrom: this._coverageOptions.collectCoverageOnlyFrom,
+        extraGlobals,
         isInternalModule,
       },
       this._cacheFS[filename],
@@ -670,6 +672,7 @@ class Runtime {
         // $FlowFixMe
         (localModule.require: LocalModuleRequire),
       ), // jest object
+      ...extraGlobals.map(thing => global[thing]),
     );
 
     this._isCurrentlyExecutingManualMock = origCurrExecutingManualMock;
diff --git i/packages/jest-runtime/src/script_transformer.js w/packages/jest-runtime/src/script_transformer.js
index a25683156..66c88e6f8 100644
--- i/packages/jest-runtime/src/script_transformer.js
+++ w/packages/jest-runtime/src/script_transformer.js
@@ -38,6 +38,7 @@ export type Options = {|
   collectCoverageOnlyFrom: ?{[key: string]: boolean, __proto__: null},
   isCoreModule?: boolean,
   isInternalModule?: boolean,
+  extraGlobals?: Array<string>,
 |};
 
 type ProjectCache = {|
@@ -305,6 +306,8 @@ export default class ScriptTransformer {
       (this._shouldTransform(filename) || instrument);
 
     try {
+      const extraGlobals = options.extraGlobals || [];
+
       if (willTransform) {
         const transformedSource = this.transformSource(
           filename,
@@ -312,11 +315,11 @@ export default class ScriptTransformer {
           instrument,
         );
 
-        wrappedCode = wrap(transformedSource.code);
+        wrappedCode = wrap(transformedSource.code, ...extraGlobals);
         sourceMapPath = transformedSource.sourceMapPath;
         mapCoverage = transformedSource.mapCoverage;
       } else {
-        wrappedCode = wrap(content);
+        wrappedCode = wrap(content, ...extraGlobals);
       }
 
       return {
@@ -517,11 +520,25 @@ const calcIgnorePatternRegexp = (config: ProjectConfig): ?RegExp => {
   return new RegExp(config.transformIgnorePatterns.join('|'));
 };
 
-const wrap = content =>
-  '({"' +
-  ScriptTransformer.EVAL_RESULT_VARIABLE +
-  '":function(module,exports,require,__dirname,__filename,global,jest){' +
-  content +
-  '\n}});';
+const wrap = (content, ...extras) => {
+  const args = [
+    'module',
+    'exports',
+    'require',
+    '__dirname',
+    '__filename',
+    'global',
+    'jest',
+    ...extras,
+  ];
+
+  return (
+    '({"' +
+    ScriptTransformer.EVAL_RESULT_VARIABLE +
+    `":function(${args.join(',')}){` +
+    content +
+    '\n}});'
+  );
+};
 
 ScriptTransformer.EVAL_RESULT_VARIABLE = 'Object.<anonymous>';

extraGlobals would come from some config option

@SimenB
Copy link
Member

SimenB commented Dec 3, 2018

Doing that to the reproduction in #5163 results in this:

 PASS  ./pixelmatch.spec.js
  ● Console

    console.time pixelmatch.js:9
      reading screenshot-a:: 1ms
    console.time pixelmatch.js:13
      reading screenshot-b:: 1ms
    console.time pixelmatch.js:24
      running image comparison:: 209ms
    console.time pixelmatch.js:28
      creating diff buffer:: 477ms
    console.time pixelmatch.js:32
      writing diff file:: 1ms

So it seems to work, and doesn't require a custom env. It also reuses the wrapping we already do, so no extra wrapping not already present.

@corevo
Copy link
Contributor Author

corevo commented Dec 4, 2018

I was thinking of using the environment in case you want to initialize something and pass that as a global as well.
But for the use case we are talking about your suggestion is just fine.
Do you want me to refactor and wire it up to the config?

@SimenB
Copy link
Member

SimenB commented Dec 4, 2018

I think it's a more correct change. People can still make their own env if they want, but this allows them to just say "I want Math" and leave transforming the source to the transformer

@corevo corevo force-pushed the environment-local-lookup branch 2 times, most recently from 321110b to 830557c Compare December 4, 2018 14:15
@codecov-io
Copy link

codecov-io commented Dec 4, 2018

Codecov Report

Merging #7454 into master will decrease coverage by 0.68%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7454      +/-   ##
==========================================
- Coverage   67.47%   66.79%   -0.69%     
==========================================
  Files         247      242       -5     
  Lines        9514     9382     -132     
  Branches        5        5              
==========================================
- Hits         6420     6267     -153     
- Misses       3092     3113      +21     
  Partials        2        2
Impacted Files Coverage Δ
packages/jest-config/src/ValidConfig.js 100% <ø> (ø) ⬆️
packages/jest-config/src/index.js 19.35% <ø> (ø) ⬆️
packages/jest-config/src/normalize.js 85.53% <ø> (+2.4%) ⬆️
packages/jest-runtime/src/script_transformer.js 88.6% <100%> (+0.14%) ⬆️
packages/jest-runtime/src/index.js 76.41% <50%> (-0.59%) ⬇️
packages/jest-cli/src/testResultHelpers.js 9.09% <0%> (-63.64%) ⬇️
packages/jest-cli/src/ReporterDispatcher.js 75% <0%> (-12.5%) ⬇️
packages/jest-resolve/src/isBuiltinModule.js 66.66% <0%> (-8.34%) ⬇️
packages/jest-cli/src/TestScheduler.js 65.32% <0%> (-8.07%) ⬇️
...r/src/__performance_tests__/workers/worker_farm.js 0% <0%> (ø) ⬆️
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 700e0da...e986629. Read the comment docs.

@corevo
Copy link
Contributor Author

corevo commented Dec 4, 2018

I went with the direction you were explaining, if you like it, I'll tidy it up with tests and docs.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

This needs to be added to https://jestjs.io/docs/en/configuration

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -26,6 +26,7 @@ const DEFAULT_GLOBAL_CONFIG: GlobalConfig = {
enabledTestsMap: null,
errorOnDeprecated: false,
expand: false,
extraGlobals: [],
Copy link
Member

Choose a reason for hiding this comment

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

@rickhanlonii thoughts on naming here?

@corevo corevo force-pushed the environment-local-lookup branch 2 times, most recently from fc2f25b to 3dd3c87 Compare December 5, 2018 09:36
packages/jest-runtime/src/index.js Outdated Show resolved Hide resolved
packages/jest-runtime/src/index.js Outdated Show resolved Hide resolved
@SimenB
Copy link
Member

SimenB commented Dec 24, 2018

@rickhanlonii gonna merge, feel free to yell at me if you don't like the name 😀

@SimenB SimenB merged commit a6eff76 into jestjs:master Dec 24, 2018
@SimenB SimenB changed the title Allow environment to transform test scripts Add extraGlobals option Jan 20, 2019
captain-yossarian pushed a commit to captain-yossarian/jest that referenced this pull request Jul 18, 2019
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calls to Math are several orders of magnitude slower than when run outside of Jest
6 participants