├── examples ├── react-native │ ├── .watchmanconfig │ ├── .babelrc │ ├── android │ │ ├── settings.gradle │ │ ├── app │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── res │ │ │ │ ├── values │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ └── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── jestrn │ │ │ │ └── MainActivity.java │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ └── keystores │ │ │ ├── debug.keystore.properties │ │ │ └── BUCK │ ├── .buckconfig │ ├── index.ios.js │ ├── index.android.js │ ├── ios │ │ └── jestrn │ │ │ ├── AppDelegate.h │ │ │ └── main.m │ ├── package.json │ └── .gitignore ├── jquery │ ├── .babelrc │ ├── package.json │ ├── displayUser.js │ └── fetchCurrentUser.js ├── timer │ ├── .babelrc │ ├── package.json │ ├── timerGame.js │ └── infiniteTimerGame.js ├── manual_mocks │ ├── .babelrc │ ├── package.json │ └── FileSummarizer.js ├── enzyme │ ├── .babelrc │ ├── package.json │ └── __tests__ │ │ └── CheckboxWithLabel-test.js ├── getting_started │ ├── .babelrc │ ├── sum.js │ ├── package.json │ └── sum.test.js ├── react │ ├── .babelrc │ └── package.json ├── snapshot │ ├── .babelrc │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── Clock.react-test.js.snap │ │ └── Clock.react-test.js │ └── package.json ├── typescript │ ├── sum.ts │ ├── tsconfig.json │ ├── sub.ts │ ├── __tests__ │ │ ├── sub-test.ts │ │ ├── sum-test.ts │ │ └── sum-test.js │ ├── sum.js │ ├── preprocessor.js │ └── package.json ├── .eslintrc ├── async │ ├── .babelrc │ ├── user.js │ ├── package.json │ ├── __mocks__ │ │ └── request.js │ └── request.js └── README.md ├── .npmignore ├── integration_tests ├── coverage_report │ ├── .gitignore │ ├── package.json │ ├── setup.js │ ├── other-file.js │ ├── __mocks__ │ │ └── sum_dependency.js │ ├── sum_dependency.js │ └── sum.js ├── resolve │ ├── test1.json │ ├── test2.json │ ├── test3.json │ ├── test4.json │ ├── package.json │ ├── test1.js │ ├── test2.js │ ├── test3.js │ ├── test1.native.js │ ├── test2.native.js │ └── test1.android.js ├── native-async-mock │ ├── .babelrc │ ├── package.json │ ├── __tests__ │ │ └── native-async-mock-test.js │ └── native.js ├── .eslintrc ├── transform │ ├── multiple-transformers │ │ ├── .babelrc │ │ ├── jsPreprocessor.js │ │ ├── package.json │ │ └── filePreprocessor.js │ ├── babel-jest │ │ ├── .babelrc │ │ ├── package.json │ │ ├── not-covered.js │ │ ├── __tests__ │ │ │ └── babel-jest-test.js │ │ └── this-directory-is-covered │ │ │ └── excluded-from-coverage.js │ ├── custom-instrumenting-preprocessor │ │ ├── package.json │ │ └── src │ │ │ ├── some-other-file.js │ │ │ └── index.js │ └── no-babel-jest │ │ ├── package.json │ │ ├── __tests__ │ │ ├── passes-with-no-babel-jest.js │ │ └── fails-with-syntax-error-test.js │ │ └── this-directory-is-covered │ │ └── excluded-from-coverage.js ├── env-test │ ├── package.json │ └── __tests__ │ │ └── env-test.js ├── failures │ ├── package.json │ └── __tests__ │ │ ├── throw-number-test.js │ │ ├── throw-object-test.js │ │ └── throw-string-test.js ├── list_tests │ ├── package.json │ └── __tests__ │ │ └── dummy-test.js ├── snapshot │ └── package.json ├── stack_trace │ ├── package.json │ └── __tests__ │ │ ├── runtime-error-test.js │ │ ├── stack-trace-test.js │ │ └── stack-trace-without-message-test.js ├── test-in-root │ ├── package.json │ ├── foo.js │ ├── spec.js │ ├── test.js │ └── footest.js ├── empty_suite_error │ ├── package.json │ └── __tests__ │ │ └── empty-suite-test.js ├── jasmine_async │ ├── package.json │ └── __tests__ │ │ ├── promise_xit-test.js │ │ └── concurrent-test.js ├── snapshot-escape │ ├── package.json │ └── __tests__ │ │ ├── snapshot-escape-substitution-test.js │ │ └── snapshot-test.js ├── test-environment │ ├── package.json │ └── __tests__ │ │ └── env-test.js ├── testNamePattern │ ├── package.json │ └── __tests__ │ │ └── testNamePattern-test.js ├── toMatchSnapshot │ └── package.json ├── verbose_reporter │ ├── package.json │ └── __tests__ │ │ └── verbose-test.js ├── regex-(char-in-path │ ├── package.json │ └── __tests__ │ │ └── regex-(char-in-path.test.js ├── testResultsProcessor │ ├── package.json │ ├── __tests__ │ │ └── processor-test.js │ └── processor.js ├── runtime-internal-module-registry │ └── package.json ├── toThrowErrorMatchingSnapshot │ └── package.json ├── auto-clear-mocks │ ├── without-auto-clear │ │ ├── package.json │ │ └── index.js │ └── with-auto-clear │ │ ├── package.json │ │ └── index.js ├── auto-reset-mocks │ ├── without-auto-reset │ │ ├── package.json │ │ └── index.js │ └── with-auto-reset │ │ ├── package.json │ │ └── index.js ├── console │ ├── package.json │ └── __tests__ │ │ └── console-test.js ├── set_immediate │ ├── package.json │ └── __tests__ │ │ └── set-immediate-test.js ├── compare-dom-nodes │ ├── package.json │ └── __tests__ │ │ └── failed-assertion.js ├── setup_test_framework_script_file_cli_config │ ├── package.json │ ├── setup1.js │ ├── setup_hooks_into_runner.js │ └── __tests__ │ │ ├── test1-test.js │ │ ├── test2-test.js │ │ └── runner_patch-test.js ├── json_reporter │ ├── package.json │ ├── sum.js │ └── __tests__ │ │ └── sum-test.js ├── timer-resetMocks │ ├── after_resetAllMocks │ │ ├── package.json │ │ ├── index.js │ │ └── timer_and_mock.test.js │ └── with_resetMocks │ │ ├── package.json │ │ ├── timer_with_mock.test.js │ │ └── index.js ├── node_path │ ├── package.json │ ├── src │ │ └── path │ │ │ └── file.js │ └── __tests__ │ │ └── node_path-test.js ├── typescript-coverage │ ├── covered.ts │ ├── __tests__ │ │ └── covered-test.ts │ ├── yarn.lock │ ├── package.json │ └── typescript-preprocessor.js ├── coverage-remapping │ ├── __tests__ │ │ └── covered-test.ts │ ├── yarn.lock │ ├── covered.ts │ └── package.json ├── babel-plugin-jest-hoist │ ├── .babelrc │ ├── package.json │ ├── banana.js │ ├── __test_modules__ │ │ ├── a.js │ │ ├── b.js │ │ ├── c.js │ │ ├── d.js │ │ ├── e.js │ │ ├── Mocked.js │ │ └── Unmocked.js │ └── mock-file.js ├── custom_reporters │ ├── package.json │ ├── add.js │ └── __tests__ │ │ ├── add-test.js │ │ └── add-fail-test.js ├── package.json ├── snapshot-serializers │ ├── package.json │ ├── plugins │ │ ├── foo │ │ │ └── index.js │ │ └── bar.js │ ├── utils.js │ └── transformer.js └── __tests__ │ ├── __snapshots__ │ ├── testNamePattern-test.js.snap │ ├── timeouts-test.js.snap │ └── typescript-coverage-test.js.snap │ ├── symbol-test.js │ ├── global-test.js │ ├── require-v8-module-test.js │ ├── resolve-test.js │ ├── json-test.js │ └── node_path-test.js ├── packages ├── jest-runtime │ ├── src │ │ └── __tests__ │ │ │ ├── test_root │ │ │ ├── NativeModule.node │ │ │ ├── JSONFile.json │ │ │ ├── UTF8WithBOM.json │ │ │ ├── haste-package │ │ │ │ ├── package.json │ │ │ │ └── core │ │ │ │ │ └── module.js │ │ │ ├── nested1 │ │ │ │ └── nested2 │ │ │ │ │ └── nested3.js │ │ │ ├── node_modules │ │ │ │ ├── jest-resolve-test │ │ │ │ │ ├── node.js │ │ │ │ │ ├── browser.js │ │ │ │ │ └── package.json │ │ │ │ ├── not-a-haste-package │ │ │ │ │ ├── package.json │ │ │ │ │ └── core.js │ │ │ │ └── npm3-transitive-dep │ │ │ │ │ ├── internal-code.js │ │ │ │ │ └── index.js │ │ │ ├── __mocks__ │ │ │ │ ├── nested1 │ │ │ │ │ └── nested2 │ │ │ │ │ │ └── nested3.js │ │ │ │ └── ExclusivelyManualMock.js │ │ │ ├── mapped_dir │ │ │ │ └── moduleInMapped.js │ │ │ ├── module_dir │ │ │ │ ├── my-module │ │ │ │ │ ├── package.json │ │ │ │ │ └── core.js │ │ │ │ └── moduleDirModule.js │ │ │ ├── depOnMappedModule.js │ │ │ ├── mapped_module_test.js │ │ │ ├── throwing.js │ │ │ ├── MyDirectoryModule │ │ │ │ └── index.js │ │ │ ├── UTF8WithBOM.js │ │ │ ├── internal-root.js │ │ │ ├── internal-module.js │ │ │ ├── subdir2 │ │ │ │ └── module_dir │ │ │ │ │ ├── my-module │ │ │ │ │ └── core.js │ │ │ │ │ └── moduleDirModule.js │ │ │ ├── TestModuleNameMapperResolution.jsx │ │ │ ├── platform │ │ │ │ ├── Platform.ios.js │ │ │ │ ├── Platform.js │ │ │ │ ├── Platform.android.js │ │ │ │ └── Platform.native.js │ │ │ ├── throwing-fn.js │ │ │ ├── GlobalImageStub.js │ │ │ ├── ManuallyMocked.js │ │ │ ├── test-preprocessor.js │ │ │ ├── RelativeImageStub.js │ │ │ ├── OnlyRequiredFromMock.js │ │ │ ├── logging.js │ │ │ ├── haste-modules │ │ │ │ └── FooRenderUtil.js │ │ │ └── ModuleWithSideEffects.js │ │ │ ├── module_dir │ │ │ ├── moduleDirectoryFile.js │ │ │ └── to-be-instrumented.js │ │ │ └── test_root_with_dup_mocks │ │ │ ├── subdir1 │ │ │ ├── MyModule.js │ │ │ └── __mocks__ │ │ │ │ └── MyModule.js │ │ │ └── subdir2 │ │ │ ├── MyModule.js │ │ │ ├── __mocks__ │ │ │ └── MyModule.js │ │ │ └── module_dir │ │ │ └── moduleDirModule.js │ ├── .npmignore │ └── bin │ │ └── jest-runtime.js ├── jest-cli │ ├── src │ │ ├── __tests__ │ │ │ ├── test_root │ │ │ │ ├── module.jsx │ │ │ │ ├── module.foobar │ │ │ │ ├── no tests.js │ │ │ │ ├── __testtests__ │ │ │ │ │ ├── test.jsx │ │ │ │ │ ├── test.foobar │ │ │ │ │ ├── do-not-match-me.txt │ │ │ │ │ ├── not-really-a-test.txt │ │ │ │ │ └── test.js │ │ │ │ └── .hiddenFolder │ │ │ │ │ └── not-really-a-test.txt │ │ │ └── __snapshots__ │ │ │ │ └── watch-test.js.snap │ │ ├── assets │ │ │ └── jest_logo.png │ │ └── lib │ │ │ ├── terminalUtils.js │ │ │ └── colorize.js │ ├── .npmignore │ ├── bin │ │ └── jest.js │ └── README.md ├── jest │ ├── .npmignore │ ├── bin │ │ └── jest.js │ ├── src │ │ └── jest.js │ └── README.md ├── babel-jest │ ├── .npmignore │ └── package.json ├── jest-config │ ├── .npmignore │ └── src │ │ └── constants.js ├── jest-diff │ ├── .npmignore │ └── package.json ├── jest-mock │ ├── .npmignore │ └── package.json ├── jest-repl │ ├── .npmignore │ ├── package.json │ └── bin │ │ └── jest-repl.js ├── jest-util │ ├── .npmignore │ ├── src │ │ ├── setGlobal.js │ │ ├── clearLine.js │ │ ├── __tests__ │ │ │ └── __snapshots__ │ │ │ │ └── FakeTimers-test.js.snap │ │ └── NullConsole.js │ └── package.json ├── jest-docblock │ ├── .npmignore │ └── package.json ├── jest-get-type │ ├── .npmignore │ └── package.json ├── jest-haste-map │ ├── .npmignore │ ├── package.json │ └── src │ │ └── __tests__ │ │ └── hasteImpl.js ├── jest-jasmine2 │ ├── .npmignore │ ├── src │ │ ├── __tests__ │ │ │ ├── __snapshots__ │ │ │ │ ├── matchers-test.js.snap │ │ │ │ └── expectationResultFactory-test.js.snap │ │ │ ├── it_to_test_alias-test.js │ │ │ └── matchers-test.js │ │ └── ExpectationFailed.js │ └── package.json ├── jest-matchers │ ├── .npmignore │ ├── src │ │ └── __tests__ │ │ │ └── __snapshots__ │ │ │ └── extend-test.js.snap │ └── package.json ├── jest-regex-util │ ├── .npmignore │ └── package.json ├── jest-resolve │ ├── .npmignore │ ├── package.json │ └── src │ │ └── __mocks__ │ │ └── userResolver.js ├── jest-snapshot │ ├── .npmignore │ ├── src │ │ └── __tests__ │ │ │ └── plugins │ │ │ ├── bar.js │ │ │ └── foo.js │ └── package.json ├── jest-validate │ ├── .npmignore │ └── package.json ├── pretty-format │ ├── .npmignore │ ├── package.json │ └── src │ │ └── plugins │ │ └── lib │ │ └── escapeHTML.js ├── babel-preset-jest │ ├── .npmignore │ ├── package.json │ └── index.js ├── eslint-plugin-jest │ ├── .npmignore │ └── package.json ├── jest-changed-files │ ├── .npmignore │ ├── package.json │ └── src │ │ └── index.js ├── jest-editor-support │ ├── .npmignore │ ├── yarn.lock │ ├── package.json │ ├── README.md │ └── src │ │ └── __tests__ │ │ └── parsers │ │ └── BabylonParser-test.js ├── jest-environment-node │ ├── .npmignore │ └── package.json ├── jest-matcher-utils │ ├── .npmignore │ └── package.json ├── jest-message-util │ ├── .npmignore │ ├── package.json │ └── src │ │ └── __tests__ │ │ └── __snapshots__ │ │ └── messages-test.js.snap ├── babel-plugin-jest-hoist │ ├── .npmignore │ └── package.json ├── jest-environment-jsdom │ ├── .npmignore │ └── package.json ├── jest-resolve-dependencies │ ├── .npmignore │ ├── src │ │ └── __tests__ │ │ │ └── __fixtures__ │ │ │ ├── __snapshots__ │ │ │ └── related-test.js.snap │ │ │ ├── file.js │ │ │ ├── related-test.js │ │ │ └── file-test.js │ └── package.json ├── jest-test-typescript-parser │ ├── .npmignore │ ├── yarn.lock │ ├── package.json │ └── src │ │ └── __tests__ │ │ └── TypeScriptParser-test.js ├── jest-phabricator │ └── package.json ├── jest-circus │ └── package.json └── eslint-config-fb-strict │ └── package.json ├── scripts └── .eslintrc ├── website ├── src │ └── jest │ │ ├── img │ │ ├── favicon.png │ │ ├── oss_logo.png │ │ ├── logos │ │ │ ├── artsy.png │ │ │ ├── cisco.png │ │ │ ├── ebay.png │ │ │ ├── globo.png │ │ │ ├── hudl.png │ │ │ ├── ibm.png │ │ │ ├── klm.png │ │ │ ├── nhl.png │ │ │ ├── nyt.png │ │ │ ├── xing.png │ │ │ ├── deezer.png │ │ │ ├── discord.png │ │ │ ├── egghead.png │ │ │ ├── elastic.png │ │ │ ├── intuit.png │ │ │ ├── oculus.png │ │ │ ├── paypal.png │ │ │ ├── quiqup.png │ │ │ ├── reddit.png │ │ │ ├── spotify.png │ │ │ ├── target.png │ │ │ ├── trivago.png │ │ │ ├── truffls.png │ │ │ ├── twitter.png │ │ │ ├── wowair.png │ │ │ ├── Help-Clean.png │ │ │ ├── audiense.png │ │ │ ├── automattic.png │ │ │ ├── coinbase.png │ │ │ ├── coursera.png │ │ │ ├── facebook.png │ │ │ ├── instagram.png │ │ │ ├── intercom.png │ │ │ ├── pinterest.png │ │ │ ├── seatgeek.png │ │ │ ├── soundcloud.png │ │ │ ├── kickstarter.png │ │ │ ├── sproutsocial.png │ │ │ ├── formidablelabs.png │ │ │ └── giantmachines.png │ │ ├── opengraph.png │ │ ├── blog │ │ │ ├── 15-watch.gif │ │ │ ├── 16-watch.gif │ │ │ ├── snapshot.png │ │ │ ├── 15-console.png │ │ │ ├── 15-failure1.png │ │ │ ├── 15-failure2.png │ │ │ ├── 16-reporter.gif │ │ │ ├── 19-validate.png │ │ │ ├── Scheduling1.png │ │ │ ├── Scheduling2.png │ │ │ ├── 16-snapshots.png │ │ │ ├── 19-cli-error.png │ │ │ ├── 20-typeahead.png │ │ │ ├── 19-skipped-tests.png │ │ │ ├── 20-multi-runner.gif │ │ │ ├── 20-testing-apis.png │ │ │ ├── 19-typeahead-name.gif │ │ │ ├── 19-snapshot-version.png │ │ │ ├── 19-typeahead-pattern.gif │ │ │ └── 19-asymmetric-matchers.png │ │ ├── content │ │ │ ├── joker.png │ │ │ ├── runner.png │ │ │ ├── feature-fast.png │ │ │ ├── feature-mocking.png │ │ │ ├── camera-with-flash.png │ │ │ ├── failedSnapshotTest.png │ │ │ ├── feature-coverage.png │ │ │ ├── feature-typescript.png │ │ │ ├── feature-config-react.png │ │ │ └── female-technologist.png │ │ └── favicon │ │ │ ├── favicon.ico │ │ │ ├── favicon-16x16.png │ │ │ ├── favicon-32x32.png │ │ │ ├── mstile-70x70.png │ │ │ ├── mstile-144x144.png │ │ │ ├── mstile-150x150.png │ │ │ ├── mstile-310x150.png │ │ │ ├── mstile-310x310.png │ │ │ ├── apple-touch-icon.png │ │ │ ├── android-chrome-192x192.png │ │ │ ├── android-chrome-512x512.png │ │ │ ├── browserconfig.xml │ │ │ └── manifest.json │ │ ├── help.js │ │ ├── index.js │ │ ├── users.js │ │ ├── en │ │ ├── help.js │ │ ├── index.js │ │ ├── users.js │ │ └── support.js │ │ └── support.js └── core │ ├── H2.js │ ├── center.js │ ├── unindent.js │ └── Button.js ├── lerna.json ├── docs └── en │ └── TutorialWebpack.md ├── fixtures ├── declarationWithoutAssignment.example ├── nested_its.example └── global_its.example ├── .editorconfig ├── .travis.yml ├── .eslintignore ├── .vscode ├── extensions.json └── settings.json ├── .babelrc ├── jest ├── types ├── Global.js ├── Jasmine.js ├── Process.js ├── Reporters.js ├── Resolve.js ├── Mock.js └── Console.js ├── jsconfig.json ├── .eslintrc-docs.json ├── .github └── PULL_REQUEST_TEMPLATE.md ├── appveyor.yml └── .flowconfig /examples/react-native/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | -------------------------------------------------------------------------------- /integration_tests/coverage_report/.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | -------------------------------------------------------------------------------- /examples/jquery/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env"] 3 | } 4 | -------------------------------------------------------------------------------- /examples/timer/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env"] 3 | } 4 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/NativeModule.node: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/manual_mocks/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env"] 3 | } 4 | -------------------------------------------------------------------------------- /examples/enzyme/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "react"] 3 | } 4 | -------------------------------------------------------------------------------- /examples/getting_started/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env"] 3 | } 4 | -------------------------------------------------------------------------------- /examples/react/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "react"] 3 | } 4 | -------------------------------------------------------------------------------- /examples/snapshot/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "react"] 3 | } 4 | -------------------------------------------------------------------------------- /packages/jest-cli/src/__tests__/test_root/module.jsx: -------------------------------------------------------------------------------- 1 | // module.jsx 2 | -------------------------------------------------------------------------------- /integration_tests/resolve/test1.json: -------------------------------------------------------------------------------- 1 | { 2 | "extension": "json" 3 | } 4 | -------------------------------------------------------------------------------- /integration_tests/resolve/test2.json: -------------------------------------------------------------------------------- 1 | { 2 | "extension": "json" 3 | } 4 | -------------------------------------------------------------------------------- /integration_tests/resolve/test3.json: -------------------------------------------------------------------------------- 1 | { 2 | "extension": "json" 3 | } 4 | -------------------------------------------------------------------------------- /integration_tests/resolve/test4.json: -------------------------------------------------------------------------------- 1 | { 2 | "extension": "json" 3 | } 4 | -------------------------------------------------------------------------------- /packages/jest-cli/src/__tests__/test_root/module.foobar: -------------------------------------------------------------------------------- 1 | // module.foobar 2 | -------------------------------------------------------------------------------- /examples/react-native/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "react-native"] 3 | } 4 | -------------------------------------------------------------------------------- /packages/jest-cli/src/__tests__/test_root/no tests.js: -------------------------------------------------------------------------------- 1 | // no tests for this one 2 | -------------------------------------------------------------------------------- /integration_tests/native-async-mock/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"] 3 | } 4 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/JSONFile.json: -------------------------------------------------------------------------------- 1 | {"isJSONModule": true} 2 | -------------------------------------------------------------------------------- /packages/jest/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/babel-jest/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-cli/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-config/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-diff/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-mock/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-repl/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-util/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-docblock/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-get-type/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-haste-map/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-jasmine2/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-matchers/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-regex-util/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-resolve/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-runtime/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-snapshot/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-validate/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/pretty-format/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /scripts/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "babel/func-params-comma-dangle": 0 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /examples/react-native/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'jestrn' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /packages/babel-preset-jest/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/eslint-plugin-jest/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-changed-files/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-editor-support/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-environment-node/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-matcher-utils/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-message-util/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /integration_tests/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "babel/func-params-comma-dangle": 0 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/transform/multiple-transformers/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "react"] 3 | } 4 | -------------------------------------------------------------------------------- /packages/babel-plugin-jest-hoist/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-environment-jsdom/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /packages/jest-resolve-dependencies/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /integration_tests/env-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/failures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/list_tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/snapshot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/stack_trace/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/test-in-root/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/UTF8WithBOM.json: -------------------------------------------------------------------------------- 1 | {"isJSONModuleEncodedInUTF8WithBOM": true} 2 | -------------------------------------------------------------------------------- /packages/jest-test-typescript-parser/.npmignore: -------------------------------------------------------------------------------- 1 | **/__mocks__/** 2 | **/__tests__/** 3 | src 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /integration_tests/empty_suite_error/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/jasmine_async/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/snapshot-escape/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/test-environment/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/testNamePattern/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/toMatchSnapshot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/verbose_reporter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/jest-cli/src/__tests__/test_root/__testtests__/test.jsx: -------------------------------------------------------------------------------- 1 | // test.jsx 2 | 3 | require('../module.jsx'); 4 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/haste-package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "haste-package" 3 | } 4 | -------------------------------------------------------------------------------- /integration_tests/regex-(char-in-path/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/testResultsProcessor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/transform/babel-jest/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "transform-flow-strip-types" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/nested1/nested2/nested3.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.isMock = false; 4 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/node_modules/jest-resolve-test/node.js: -------------------------------------------------------------------------------- 1 | module.exports.isBrowser = false; 2 | -------------------------------------------------------------------------------- /website/src/jest/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon.png -------------------------------------------------------------------------------- /website/src/jest/img/oss_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/oss_logo.png -------------------------------------------------------------------------------- /examples/typescript/sum.ts: -------------------------------------------------------------------------------- 1 | function sum(a: number, b: number): number { 2 | return a + b; 3 | } 4 | 5 | export = sum; 6 | -------------------------------------------------------------------------------- /packages/jest-cli/src/__tests__/test_root/__testtests__/test.foobar: -------------------------------------------------------------------------------- 1 | // test.foobar 2 | 3 | require('../module.foobar'); 4 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/node_modules/jest-resolve-test/browser.js: -------------------------------------------------------------------------------- 1 | module.exports.isBrowser = true; 2 | -------------------------------------------------------------------------------- /website/src/jest/img/logos/artsy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/artsy.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/cisco.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/cisco.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/ebay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/ebay.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/globo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/globo.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/hudl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/hudl.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/ibm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/ibm.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/klm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/klm.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/nhl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/nhl.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/nyt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/nyt.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/xing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/xing.png -------------------------------------------------------------------------------- /website/src/jest/img/opengraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/opengraph.png -------------------------------------------------------------------------------- /examples/typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "jsx": "react" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /integration_tests/runtime-internal-module-registry/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/toThrowErrorMatchingSnapshot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/__mocks__/nested1/nested2/nested3.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.isMock = true; 4 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/mapped_dir/moduleInMapped.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = `in_mapped`; 4 | -------------------------------------------------------------------------------- /website/src/jest/img/blog/15-watch.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/15-watch.gif -------------------------------------------------------------------------------- /website/src/jest/img/blog/16-watch.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/16-watch.gif -------------------------------------------------------------------------------- /website/src/jest/img/blog/snapshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/snapshot.png -------------------------------------------------------------------------------- /website/src/jest/img/content/joker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/content/joker.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/deezer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/deezer.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/discord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/discord.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/egghead.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/egghead.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/elastic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/elastic.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/intuit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/intuit.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/oculus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/oculus.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/paypal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/paypal.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/quiqup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/quiqup.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/reddit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/reddit.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/spotify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/spotify.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/target.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/target.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/trivago.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/trivago.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/truffls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/truffls.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/twitter.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/wowair.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/wowair.png -------------------------------------------------------------------------------- /integration_tests/auto-clear-mocks/without-auto-clear/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/auto-reset-mocks/without-auto-reset/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /integration_tests/console/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node", 4 | "verbose": false 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/jest-cli/src/__tests__/test_root/__testtests__/do-not-match-me.txt: -------------------------------------------------------------------------------- 1 | // do-no-match-me.txt 2 | 3 | require('../module.txt'); 4 | -------------------------------------------------------------------------------- /website/src/jest/img/blog/15-console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/15-console.png -------------------------------------------------------------------------------- /website/src/jest/img/blog/15-failure1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/15-failure1.png -------------------------------------------------------------------------------- /website/src/jest/img/blog/15-failure2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/15-failure2.png -------------------------------------------------------------------------------- /website/src/jest/img/blog/16-reporter.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/16-reporter.gif -------------------------------------------------------------------------------- /website/src/jest/img/blog/19-validate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/19-validate.png -------------------------------------------------------------------------------- /website/src/jest/img/blog/Scheduling1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/Scheduling1.png -------------------------------------------------------------------------------- /website/src/jest/img/blog/Scheduling2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/Scheduling2.png -------------------------------------------------------------------------------- /website/src/jest/img/content/runner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/content/runner.png -------------------------------------------------------------------------------- /website/src/jest/img/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon/favicon.ico -------------------------------------------------------------------------------- /website/src/jest/img/logos/Help-Clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/Help-Clean.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/audiense.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/audiense.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/automattic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/automattic.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/coinbase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/coinbase.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/coursera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/coursera.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/facebook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/facebook.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/instagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/instagram.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/intercom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/intercom.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/pinterest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/pinterest.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/seatgeek.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/seatgeek.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/soundcloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/soundcloud.png -------------------------------------------------------------------------------- /integration_tests/set_immediate/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node", 4 | "timers": "fake" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/jest-cli/src/__tests__/test_root/.hiddenFolder/not-really-a-test.txt: -------------------------------------------------------------------------------- 1 | // not-really-a-test.txt 2 | 3 | require('../module.txt'); 4 | -------------------------------------------------------------------------------- /packages/jest-cli/src/__tests__/test_root/__testtests__/not-really-a-test.txt: -------------------------------------------------------------------------------- 1 | // not-really-a-test.txt 2 | 3 | require('../module.txt'); 4 | -------------------------------------------------------------------------------- /packages/jest-cli/src/assets/jest_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/packages/jest-cli/src/assets/jest_logo.png -------------------------------------------------------------------------------- /website/src/jest/img/blog/16-snapshots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/16-snapshots.png -------------------------------------------------------------------------------- /website/src/jest/img/blog/19-cli-error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/19-cli-error.png -------------------------------------------------------------------------------- /website/src/jest/img/blog/20-typeahead.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/20-typeahead.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/kickstarter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/kickstarter.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/sproutsocial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/sproutsocial.png -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | jestrn 3 | 4 | -------------------------------------------------------------------------------- /integration_tests/compare-dom-nodes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "automock": true, 4 | "testEnvironment": "jsdom" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /integration_tests/setup_test_framework_script_file_cli_config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/module_dir/my-module/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-module", 3 | "main": "./core.js" 4 | } 5 | -------------------------------------------------------------------------------- /website/src/jest/img/blog/19-skipped-tests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/19-skipped-tests.png -------------------------------------------------------------------------------- /website/src/jest/img/blog/20-multi-runner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/20-multi-runner.gif -------------------------------------------------------------------------------- /website/src/jest/img/blog/20-testing-apis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/20-testing-apis.png -------------------------------------------------------------------------------- /website/src/jest/img/content/feature-fast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/content/feature-fast.png -------------------------------------------------------------------------------- /website/src/jest/img/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /website/src/jest/img/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /website/src/jest/img/favicon/mstile-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon/mstile-70x70.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/formidablelabs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/formidablelabs.png -------------------------------------------------------------------------------- /website/src/jest/img/logos/giantmachines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/logos/giantmachines.png -------------------------------------------------------------------------------- /integration_tests/json_reporter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node", 4 | "coverageReporters": ["json"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /website/src/jest/img/blog/19-typeahead-name.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/19-typeahead-name.gif -------------------------------------------------------------------------------- /website/src/jest/img/content/feature-mocking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/content/feature-mocking.png -------------------------------------------------------------------------------- /website/src/jest/img/favicon/mstile-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon/mstile-144x144.png -------------------------------------------------------------------------------- /website/src/jest/img/favicon/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon/mstile-150x150.png -------------------------------------------------------------------------------- /website/src/jest/img/favicon/mstile-310x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon/mstile-310x150.png -------------------------------------------------------------------------------- /website/src/jest/img/favicon/mstile-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon/mstile-310x310.png -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.0.0-rc.4", 3 | "version": "20.0.4", 4 | "npmClient": "yarn", 5 | "packages": [ 6 | "packages/*" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /website/src/jest/img/blog/19-snapshot-version.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/19-snapshot-version.png -------------------------------------------------------------------------------- /website/src/jest/img/blog/19-typeahead-pattern.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/19-typeahead-pattern.gif -------------------------------------------------------------------------------- /website/src/jest/img/content/camera-with-flash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/content/camera-with-flash.png -------------------------------------------------------------------------------- /website/src/jest/img/content/failedSnapshotTest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/content/failedSnapshotTest.png -------------------------------------------------------------------------------- /website/src/jest/img/content/feature-coverage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/content/feature-coverage.png -------------------------------------------------------------------------------- /website/src/jest/img/content/feature-typescript.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/content/feature-typescript.png -------------------------------------------------------------------------------- /website/src/jest/img/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /integration_tests/auto-clear-mocks/with-auto-clear/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node", 4 | "clearMocks": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /integration_tests/auto-reset-mocks/with-auto-reset/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node", 4 | "resetMocks": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /website/src/jest/img/blog/19-asymmetric-matchers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/blog/19-asymmetric-matchers.png -------------------------------------------------------------------------------- /website/src/jest/img/content/feature-config-react.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/content/feature-config-react.png -------------------------------------------------------------------------------- /website/src/jest/img/content/female-technologist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/content/female-technologist.png -------------------------------------------------------------------------------- /examples/typescript/sub.ts: -------------------------------------------------------------------------------- 1 | const sum = require('./sum'); 2 | 3 | function sub(a: number, b: number): number { 4 | return sum(a, -b); 5 | } 6 | 7 | export = sub; 8 | -------------------------------------------------------------------------------- /integration_tests/timer-resetMocks/after_resetAllMocks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node", 4 | "resetMocks": false 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/node_modules/not-a-haste-package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "not-a-haste-package", 3 | "main": "./core.js" 4 | } 5 | -------------------------------------------------------------------------------- /website/src/jest/img/favicon/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon/android-chrome-192x192.png -------------------------------------------------------------------------------- /website/src/jest/img/favicon/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/website/src/jest/img/favicon/android-chrome-512x512.png -------------------------------------------------------------------------------- /examples/react-native/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /examples/typescript/__tests__/sub-test.ts: -------------------------------------------------------------------------------- 1 | it('subtracts 5 - 1 to equal 4 in TypeScript', () => { 2 | const sub = require('../sub'); 3 | expect(sub(5, 1)).toBe(4); 4 | }); 5 | -------------------------------------------------------------------------------- /examples/typescript/sum.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | function sum(a, b) { 4 | return a + b; 5 | } 6 | 7 | module.exports = sum; 8 | -------------------------------------------------------------------------------- /examples/getting_started/sum.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | function sum(a, b) { 4 | return a + b; 5 | } 6 | 7 | module.exports = sum; 8 | -------------------------------------------------------------------------------- /examples/react-native/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/examples/react-native/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /packages/jest-cli/src/__tests__/test_root/__testtests__/test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | // test.js 4 | 5 | require('../module.jsx'); 6 | -------------------------------------------------------------------------------- /docs/en/TutorialWebpack.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: tutorial-webpack 3 | title: webpack 4 | layout: redirect 5 | permalink: docs/en/tutorial-webpack.html 6 | destinationUrl: webpack.html 7 | --- 8 | -------------------------------------------------------------------------------- /examples/react-native/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /examples/timer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "jest": "*", 4 | "babel-preset-env": "*" 5 | }, 6 | "scripts": { 7 | "test": "jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /fixtures/declarationWithoutAssignment.example: -------------------------------------------------------------------------------- 1 | let foo; 2 | var bar; 3 | 4 | test('declaration without assignments should not throw', () => { 5 | expect(true).toBe(true); 6 | }); 7 | -------------------------------------------------------------------------------- /integration_tests/timer-resetMocks/with_resetMocks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node", 4 | "resetMocks": true, 5 | "timers": "fake" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/jest-resolve-dependencies/src/__tests__/__fixtures__/__snapshots__/related-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`sample 1`] = `Object {}`; 4 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/depOnMappedModule.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const mappedTest = require('testMapped/moduleInMapped'); 4 | 5 | exports.result = mappedTest; 6 | -------------------------------------------------------------------------------- /examples/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "babel/func-params-comma-dangle": 0, 4 | "import/order": 0, 5 | "import/no-unresolved": [2, { "ignore": ["^react-native$"] }] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/getting_started/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "babel-preset-env": "*", 4 | "jest": "*" 5 | }, 6 | "scripts": { 7 | "test": "jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/manual_mocks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "babel-preset-env": "*", 4 | "jest": "*" 5 | }, 6 | "scripts": { 7 | "test": "jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /integration_tests/node_path/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node", 4 | "transform": { 5 | "^.+\\.jsx?$": "../../packages/babel-jest" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration_tests/typescript-coverage/covered.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | export = function sum(a: number, b: number): number { 4 | return a + b; 5 | } 6 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/examples/react-native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/examples/react-native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/examples/react-native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josephfrazier/jest/master/examples/react-native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/async/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env"], 3 | "plugins": [ 4 | ["transform-runtime", { 5 | "polyfill": false, 6 | "regenerator": true 7 | } 8 | ] 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /examples/react-native/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /examples/getting_started/sum.test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | test('adds 1 + 2 to equal 3', () => { 4 | const sum = require('./sum'); 5 | expect(sum(1, 2)).toBe(3); 6 | }); 7 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/node_modules/jest-resolve-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-resolve-test", 3 | "version": "1.0.0", 4 | "main": "./node.js", 5 | "browser": "./browser.js" 6 | } 7 | -------------------------------------------------------------------------------- /integration_tests/compare-dom-nodes/__tests__/failed-assertion.js: -------------------------------------------------------------------------------- 1 | /* global document */ 2 | 3 | test('a failed assertion comparing a DOM node does not crash Jest', () => { 4 | expect(document.body).toBe(null); 5 | }); 6 | -------------------------------------------------------------------------------- /integration_tests/transform/custom-instrumenting-preprocessor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "transform": { 4 | "^.+\\.js$": "/preprocessor.js" 5 | }, 6 | "testEnvironment": "node" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | -------------------------------------------------------------------------------- /examples/async/user.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | import request from './request'; 4 | 5 | export function getUserName(userID) { 6 | return request('/users/' + userID).then(user => user.name); 7 | } 8 | -------------------------------------------------------------------------------- /examples/jquery/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "babel-preset-env": "*", 4 | "jest": "*" 5 | }, 6 | "dependencies": { 7 | "jquery": "*" 8 | }, 9 | "scripts": { 10 | "test": "jest" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - "8" 5 | 6 | sudo: false 7 | 8 | cache: 9 | yarn: true 10 | directories: 11 | - ".eslintcache" 12 | - "node_modules" 13 | 14 | script: 15 | - yarn run test-ci-partial 16 | -------------------------------------------------------------------------------- /examples/snapshot/__tests__/__snapshots__/Clock.react-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`renders correctly 1`] = ` 4 |

5 | 1482363367.071 6 | seconds have ellapsed since the UNIX epoch. 7 |

8 | `; 9 | -------------------------------------------------------------------------------- /integration_tests/resolve/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "custom-resolve", 3 | "jest": { 4 | "haste": { 5 | "platforms": ["native"], 6 | "defaultPlatform": "android" 7 | }, 8 | "testEnvironment": "node" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /integration_tests/coverage-remapping/__tests__/covered-test.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | const difference = require('../covered.ts'); 3 | 4 | it('subtracts correctly', () => { 5 | expect(difference(3, 2)).toBe(1); 6 | }); 7 | -------------------------------------------------------------------------------- /examples/async/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "babel-jest": "*", 4 | "babel-plugin-transform-runtime": "*", 5 | "babel-preset-env": "*", 6 | "jest": "*" 7 | }, 8 | "scripts": { 9 | "test": "jest" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /integration_tests/native-async-mock/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node" 4 | }, 5 | "dependencies": { 6 | "babel-plugin-transform-async-to-generator": "^6.22.0", 7 | "babel-preset-es2015": "^6.24.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /integration_tests/typescript-coverage/__tests__/covered-test.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | it('adds 1 + 2 to equal 3 in TScript', ()=> { 4 | const sum = require('../covered.ts'); 5 | expect(sum(1, 2)).toBe(3); 6 | }); 7 | -------------------------------------------------------------------------------- /integration_tests/babel-plugin-jest-hoist/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "es2015", 4 | { 5 | "plugins": [ 6 | "jest-hoist", 7 | "transform-flow-strip-types" 8 | ] 9 | } 10 | ], 11 | "retainLines": true 12 | } 13 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/jest-docblock/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-docblock", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js" 10 | } 11 | -------------------------------------------------------------------------------- /examples/react-native/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 6 | -------------------------------------------------------------------------------- /integration_tests/custom_reporters/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "reporters": [ 4 | ["/reporters/TestReporter.js", { 5 | "hello": "world", 6 | "dmitrii": "abramov", 7 | "christoph": "pojer" 8 | }] 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /integration_tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "transform": { 4 | "^.+\\.js$": "/../packages/babel-jest" 5 | }, 6 | "testEnvironment": "node", 7 | "testPathIgnorePatterns": [ 8 | "/(?:.+?)/__tests__/" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /website/src/jest/help.js: -------------------------------------------------------------------------------- 1 | /* This is a generated file */ 2 | const React = require('React'); 3 | const JestHelp = require('JestHelp'); 4 | const help = React.createClass({ 5 | render() { 6 | return ; 7 | }, 8 | }); 9 | module.exports = help; 10 | -------------------------------------------------------------------------------- /packages/jest-changed-files/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-changed-files", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js" 10 | } 11 | -------------------------------------------------------------------------------- /website/src/jest/index.js: -------------------------------------------------------------------------------- 1 | /* This is a generated file */ 2 | const React = require('React'); 3 | const JestIndex = require('JestIndex'); 4 | const index = React.createClass({ 5 | render() { 6 | return ; 7 | }, 8 | }); 9 | module.exports = index; 10 | -------------------------------------------------------------------------------- /website/src/jest/users.js: -------------------------------------------------------------------------------- 1 | /* This is a generated file */ 2 | const React = require('React'); 3 | const JestUsers = require('JestUsers'); 4 | const users = React.createClass({ 5 | render() { 6 | return ; 7 | }, 8 | }); 9 | module.exports = users; 10 | -------------------------------------------------------------------------------- /packages/jest-editor-support/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | babylon@^6.14.1: 6 | version "6.17.0" 7 | resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932" 8 | -------------------------------------------------------------------------------- /website/src/jest/en/help.js: -------------------------------------------------------------------------------- 1 | /* This is a generated file */ 2 | const React = require('React'); 3 | const JestHelp = require('JestHelp'); 4 | const help = React.createClass({ 5 | render() { 6 | return ; 8 | }, 9 | }); 10 | module.exports = help; 11 | -------------------------------------------------------------------------------- /packages/babel-plugin-jest-hoist/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-plugin-jest-hoist", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js" 10 | } 11 | -------------------------------------------------------------------------------- /website/src/jest/en/index.js: -------------------------------------------------------------------------------- 1 | /* This is a generated file */ 2 | const React = require('React'); 3 | const JestIndex = require('JestIndex'); 4 | const index = React.createClass({ 5 | render() { 6 | return ; 8 | }, 9 | }); 10 | module.exports = index; 11 | -------------------------------------------------------------------------------- /website/src/jest/en/users.js: -------------------------------------------------------------------------------- 1 | /* This is a generated file */ 2 | const React = require('React'); 3 | const JestUsers = require('JestUsers'); 4 | const users = React.createClass({ 5 | render() { 6 | return ; 8 | }, 9 | }); 10 | module.exports = users; 11 | -------------------------------------------------------------------------------- /integration_tests/coverage-remapping/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | typescript@^1.8.10: 6 | version "1.8.10" 7 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-1.8.10.tgz#b475d6e0dff0bf50f296e5ca6ef9fbb5c7320f1e" 8 | -------------------------------------------------------------------------------- /integration_tests/typescript-coverage/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | typescript@^1.8.10: 6 | version "1.8.10" 7 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-1.8.10.tgz#b475d6e0dff0bf50f296e5ca6ef9fbb5c7320f1e" 8 | -------------------------------------------------------------------------------- /packages/jest-test-typescript-parser/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | typescript@^2.2.1: 6 | version "2.3.2" 7 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.2.tgz#f0f045e196f69a72f06b25fd3bd39d01c3ce9984" 8 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | **/coverage/** 2 | **/node_modules/** 3 | bin/ 4 | docs/ 5 | flow-typed/** 6 | packages/*/build/** 7 | packages/*/build-es5/** 8 | types/** 9 | website/build 10 | website/node_modules 11 | website/core/metadata*.js 12 | website/i18n/*.js 13 | website/src/jest/docs 14 | website/src/jest/blog 15 | -------------------------------------------------------------------------------- /examples/typescript/__tests__/sum-test.ts: -------------------------------------------------------------------------------- 1 | it('adds 1 + 2 to equal 3 in TScript', ()=> { 2 | const sum = require('../sum.ts'); 3 | expect(sum(1, 2)).toBe(3); 4 | }); 5 | 6 | it('adds 1 + 2 to equal 3 in JavaScript', ()=> { 7 | const sum = require('../sum.js'); 8 | expect(sum(1, 2)).toBe(3); 9 | }); 10 | -------------------------------------------------------------------------------- /integration_tests/snapshot-serializers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "testEnvironment": "node", 4 | "transform": { 5 | "^.+\\.js$": "/transformer.js" 6 | }, 7 | "snapshotSerializers": [ 8 | "./plugins/foo", 9 | "/plugins/bar" 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/jest-matchers/src/__tests__/__snapshots__/extend-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`is available globally 1`] = `"expected 15 to be divisible by 2"`; 4 | 5 | exports[`is ok if there is no message specified 1`] = `"No message was specified for this matcher."`; 6 | -------------------------------------------------------------------------------- /packages/jest-mock/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-mock", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "browser": "build-es5/index.js" 11 | } 12 | -------------------------------------------------------------------------------- /integration_tests/babel-plugin-jest-hoist/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "babel-plugin-transform-flow-strip-types": "^6.22.0", 4 | "babel-preset-es2015": "^6.9.0", 5 | "react": "^15.2.1" 6 | }, 7 | "jest": { 8 | "automock": true, 9 | "testEnvironment": "node" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /integration_tests/timer-resetMocks/with_resetMocks/timer_with_mock.test.js: -------------------------------------------------------------------------------- 1 | describe('timers', () => { 2 | it('should work before calling resetAllMocks', () => { 3 | const f = jest.fn(); 4 | setImmediate(() => f()); 5 | jest.runAllImmediates(); 6 | expect(f.mock.calls.length).toBe(1); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /examples/timer/timerGame.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | function timerGame(callback) { 4 | console.log('Ready....go!'); 5 | setTimeout(() => { 6 | console.log('Times up -- stop!'); 7 | callback && callback(); 8 | }, 1000); 9 | } 10 | 11 | module.exports = timerGame; 12 | -------------------------------------------------------------------------------- /packages/jest-regex-util/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-regex-util", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "browser": "build-es5/index.js" 11 | } 12 | -------------------------------------------------------------------------------- /integration_tests/coverage_report/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "collectCoverageFrom": [ 4 | "**/*.js", 5 | "!setup.js", 6 | "!**/node_modules/**", 7 | "!**/coverage/**" 8 | ], 9 | "testEnvironment": "node", 10 | "setupFiles": [ 11 | "/setup.js" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | ## How to run the examples: 2 | 3 | #### 1. Install jest 4 | 5 | ``` 6 | npm install 7 | ``` 8 | 9 | #### 2. Move to example 10 | 11 | ``` 12 | cd examples/jquery 13 | ``` 14 | 15 | #### 3. Install example 16 | 17 | ``` 18 | npm install 19 | ``` 20 | 21 | #### 4. Run example 22 | 23 | ``` 24 | npm test 25 | ``` 26 | -------------------------------------------------------------------------------- /integration_tests/native-async-mock/__tests__/native-async-mock-test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | 'use strict'; 4 | 5 | jest.mock('../native'); 6 | 7 | const native = require('../native'); 8 | 9 | test('mock works with native async', () => { 10 | expect(native.asyncMethod).toBeDefined(); 11 | }); 12 | -------------------------------------------------------------------------------- /website/src/jest/img/favicon/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #2b5797 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /integration_tests/native-async-mock/native.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | 'use strict'; 4 | 5 | function awaitable() { 6 | return Promise.resolve(); 7 | } 8 | 9 | module.exports.syncMethod = () => 42; 10 | 11 | module.exports.asyncMethod = async () => { 12 | await awaitable(); 13 | return 42; 14 | }; 15 | -------------------------------------------------------------------------------- /packages/jest-phabricator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-phabricator", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "dependencies": { 9 | "jest-util": "^20.0.3" 10 | }, 11 | "license": "BSD-3-Clause", 12 | "main": "build/index.js" 13 | } 14 | -------------------------------------------------------------------------------- /website/core/H2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule H2 3 | * @jsx React.DOM 4 | */ 5 | 6 | const React = require('React'); 7 | const Header = require('Header'); 8 | 9 | const H2 = React.createClass({ 10 | render() { 11 | return
{this.props.children}
; 12 | }, 13 | }); 14 | 15 | module.exports = H2; 16 | -------------------------------------------------------------------------------- /packages/jest-jasmine2/src/__tests__/__snapshots__/matchers-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`matchers proxies matchers to jest-matchers 1`] = ` 4 | "expect(received).toBe(expected) 5 | 6 | Expected value to be (using ===): 7 | 2 8 | Received: 9 | 1" 10 | `; 11 | -------------------------------------------------------------------------------- /examples/manual_mocks/FileSummarizer.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | const fs = require('fs'); 4 | 5 | function summarizeFilesInDirectorySync(directory) { 6 | return fs.readdirSync(directory).map(fileName => ({directory, fileName})); 7 | } 8 | 9 | exports.summarizeFilesInDirectorySync = summarizeFilesInDirectorySync; 10 | -------------------------------------------------------------------------------- /packages/babel-preset-jest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-preset-jest", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "index.js", 10 | "dependencies": { 11 | "babel-plugin-jest-hoist": "^20.0.3" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint", 6 | "djabraham.vscode-yaml-validation", 7 | "flowtype.flow-for-vscode", 8 | "esbenp.prettier-vscode", 9 | "Orta.vscode-jest" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /integration_tests/__tests__/__snapshots__/testNamePattern-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`testNamePattern 1`] = ` 4 | "Test Suites: 1 passed, 1 total 5 | Tests: 2 skipped, 2 passed, 4 total 6 | Snapshots: 0 total 7 | Time: <> 8 | Ran all test suites with tests matching \\"should match\\". 9 | " 10 | `; 11 | -------------------------------------------------------------------------------- /packages/jest-jasmine2/src/__tests__/__snapshots__/expectationResultFactory-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`expectationResultFactory returns the result if passed. 1`] = ` 4 | Object { 5 | "error": undefined, 6 | "matcherName": "testMatcher", 7 | "message": "Passed.", 8 | "passed": true, 9 | "stack": "", 10 | } 11 | `; 12 | -------------------------------------------------------------------------------- /packages/jest-resolve-dependencies/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-resolve-dependencies", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "dependencies": { 11 | "jest-regex-util": "^20.0.3" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "react": "15.4.2", 4 | "react-dom": "15.4.2" 5 | }, 6 | "devDependencies": { 7 | "babel-jest": "*", 8 | "babel-preset-env": "*", 9 | "babel-preset-react": "*", 10 | "jest": "*", 11 | "react-addons-test-utils": "15.4.2" 12 | }, 13 | "scripts": { 14 | "test": "jest" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "syntax-trailing-function-commas", 4 | "transform-flow-strip-types", 5 | "transform-es2015-destructuring", 6 | "transform-es2015-parameters", 7 | "transform-async-to-generator", 8 | "transform-strict-mode", 9 | ["transform-es2015-modules-commonjs", {"allowTopLevelThis": true}] 10 | ], 11 | "retainLines": true 12 | } 13 | -------------------------------------------------------------------------------- /examples/typescript/__tests__/sum-test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | it('adds 1 + 2 to equal 3 in Typescript', () => { 4 | const sum = require('../sum.ts'); 5 | expect(sum(1, 2)).toBe(3); 6 | }); 7 | 8 | it('adds 1 + 2 to equal 3 in JavaScript', () => { 9 | const sum = require('../sum.js'); 10 | expect(sum(1, 2)).toBe(3); 11 | }); 12 | -------------------------------------------------------------------------------- /integration_tests/transform/no-babel-jest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "collectCoverageOnlyFrom": { 4 | "/this-directory-is-covered/covered.js": true, 5 | "/this-directory-is-covered/excluded-from-coverage.js": true 6 | }, 7 | "coveragePathIgnorePatterns": ["excluded-from-coverage"], 8 | "testEnvironment": "node" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/jest-editor-support/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-editor-support", 3 | "version": "20.0.4", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "dependencies": { 11 | "babylon": "^6.14.1" 12 | }, 13 | "typings": "index.d.ts" 14 | } 15 | -------------------------------------------------------------------------------- /packages/jest-get-type/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-get-type", 3 | "description": "A utility function to get the type of a value", 4 | "version": "20.0.3", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/facebook/jest.git" 8 | }, 9 | "license": "BSD-3-Clause", 10 | "main": "build/index.js", 11 | "browser": "build-es5/index.js" 12 | } 13 | -------------------------------------------------------------------------------- /packages/jest-environment-node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-environment-node", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "dependencies": { 11 | "jest-mock": "^20.0.3", 12 | "jest-util": "^20.0.3" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/enzyme/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "react": "15.4.2", 4 | "react-dom": "15.4.2" 5 | }, 6 | "devDependencies": { 7 | "babel-jest": "*", 8 | "babel-preset-env": "*", 9 | "babel-preset-react": "*", 10 | "enzyme": "*", 11 | "jest": "*", 12 | "react-addons-test-utils": "15.4.2" 13 | }, 14 | "scripts": { 15 | "test": "jest" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /integration_tests/coverage_report/setup.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | global.setup = true; 10 | -------------------------------------------------------------------------------- /jest: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * Copyright (c) 2014, Facebook, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | require('./packages/jest-cli/bin/jest'); 11 | -------------------------------------------------------------------------------- /integration_tests/resolve/test1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = {extension: 'js'}; 10 | -------------------------------------------------------------------------------- /integration_tests/resolve/test2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = {extension: 'js'}; 10 | -------------------------------------------------------------------------------- /integration_tests/resolve/test3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = {extension: 'js'}; 10 | -------------------------------------------------------------------------------- /packages/jest/bin/jest.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * Copyright (c) 2014, Facebook, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | import 'jest-cli/bin/jest'; 11 | -------------------------------------------------------------------------------- /types/Global.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | export type Global = Object; 12 | -------------------------------------------------------------------------------- /types/Jasmine.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | export type Jasmine = Object; 12 | -------------------------------------------------------------------------------- /examples/jquery/displayUser.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | const $ = require('jquery'); 4 | const fetchCurrentUser = require('./fetchCurrentUser.js'); 5 | 6 | $('#button').click(() => { 7 | fetchCurrentUser(user => { 8 | const loggedText = 'Logged ' + (user.loggedIn ? 'In' : 'Out'); 9 | $('#username').text(user.fullName + ' - ' + loggedText); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /integration_tests/coverage_report/other-file.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = {a: 5}; 10 | -------------------------------------------------------------------------------- /packages/jest-test-typescript-parser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-test-typescript-parser", 3 | "version": "20.0.4", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "dependencies": { 11 | "jest-editor-support": "^20.0.4", 12 | "typescript": "^2.2.1" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /integration_tests/babel-plugin-jest-hoist/banana.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = 'banana'; 10 | -------------------------------------------------------------------------------- /examples/typescript/preprocessor.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | const tsc = require('typescript'); 4 | const tsConfig = require('./tsconfig.json'); 5 | 6 | module.exports = { 7 | process(src, path) { 8 | if (path.endsWith('.ts') || path.endsWith('.tsx')) { 9 | return tsc.transpile(src, tsConfig.compilerOptions, path, []); 10 | } 11 | return src; 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /integration_tests/node_path/src/path/file.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | module.exports = 42; 11 | -------------------------------------------------------------------------------- /integration_tests/resolve/test1.native.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = {extension: 'native.js'}; 10 | -------------------------------------------------------------------------------- /integration_tests/resolve/test2.native.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = {extension: 'native.js'}; 10 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=759670 3 | // for the documentation about the jsconfig.json format 4 | "compilerOptions": { 5 | "target": "es6", 6 | "module": "commonjs", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "exclude": [ 10 | "node_modules", 11 | "bower_components", 12 | "jspm_packages", 13 | "tmp", 14 | "temp" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /packages/jest-environment-jsdom/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-environment-jsdom", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "dependencies": { 11 | "jest-mock": "^20.0.3", 12 | "jest-util": "^20.0.3", 13 | "jsdom": "^9.12.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /integration_tests/auto-reset-mocks/with-auto-reset/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = () => {}; 10 | -------------------------------------------------------------------------------- /integration_tests/auto-reset-mocks/without-auto-reset/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = () => {}; 10 | -------------------------------------------------------------------------------- /integration_tests/resolve/test1.android.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = {extension: 'android.js'}; 10 | -------------------------------------------------------------------------------- /integration_tests/timer-resetMocks/after_resetAllMocks/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = () => {}; 10 | -------------------------------------------------------------------------------- /integration_tests/timer-resetMocks/with_resetMocks/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = () => {}; 10 | -------------------------------------------------------------------------------- /examples/react-native/index.ios.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import Intro from './Intro'; 8 | import React, {Component} from 'react'; 9 | import {AppRegistry} from 'react-native'; 10 | 11 | class App extends Component { 12 | render() { 13 | return ; 14 | } 15 | } 16 | 17 | AppRegistry.registerComponent('jestrn', () => App); 18 | -------------------------------------------------------------------------------- /.eslintrc-docs.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "react/react-in-jsx-scope": 0, 4 | "react/jsx-no-undef": 0, 5 | "jest/no-focused-tests": 0, 6 | "no-undef": 0, 7 | "no-unused-vars": 0, 8 | "consistent-return": 0, 9 | "import/no-unresolved": 0 10 | }, 11 | "description": ".eslintrc-docs.json overrides the rules specified in .eslintrc, to make it more suitable for running on code examples in docs/ folder" 12 | } 13 | -------------------------------------------------------------------------------- /examples/react-native/index.android.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import Intro from './Intro'; 8 | import React, {AppRegistry} from 'react-native'; 9 | import {Component} from 'react'; 10 | 11 | class App extends Component { 12 | render() { 13 | return ; 14 | } 15 | } 16 | 17 | AppRegistry.registerComponent('jestrn', () => App); 18 | -------------------------------------------------------------------------------- /examples/snapshot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "react": "15.4.2" 4 | }, 5 | "devDependencies": { 6 | "babel-jest": "*", 7 | "babel-preset-env": "*", 8 | "babel-preset-react": "*", 9 | "jest": "*", 10 | "react-test-renderer": "*", 11 | "regenerator-runtime": "*" 12 | }, 13 | "scripts": { 14 | "test": "jest" 15 | }, 16 | "jest": { 17 | "testEnvironment": "node" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /integration_tests/babel-plugin-jest-hoist/__test_modules__/a.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | export default () => 'unmocked'; 10 | -------------------------------------------------------------------------------- /integration_tests/babel-plugin-jest-hoist/__test_modules__/b.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | export default () => 'unmocked'; 10 | -------------------------------------------------------------------------------- /integration_tests/babel-plugin-jest-hoist/__test_modules__/c.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | export default () => 'unmocked'; 10 | -------------------------------------------------------------------------------- /integration_tests/babel-plugin-jest-hoist/__test_modules__/d.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | export default () => 'unmocked'; 10 | -------------------------------------------------------------------------------- /integration_tests/babel-plugin-jest-hoist/__test_modules__/e.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | export default () => 'unmocked'; 10 | -------------------------------------------------------------------------------- /packages/jest/src/jest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | import cli from 'jest-cli'; 12 | 13 | module.exports = cli; 14 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest.pathToJest": "yarn jest --", 3 | "editor.rulers": [ 4 | 80 5 | ], 6 | "files.exclude": { 7 | "**/.git": true, 8 | "**/node_modules": true, 9 | "**/build": true 10 | }, 11 | "prettier.parser": "flow", 12 | "prettier.printWidth": 80, 13 | "prettier.singleQuote": true, 14 | "prettier.trailingComma": "all", 15 | "prettier.semi": true, 16 | "editor.formatOnSave": true 17 | } 18 | -------------------------------------------------------------------------------- /integration_tests/coverage-remapping/covered.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | export = function difference(a: number, b: number): number { 4 | const branch1: boolean = true 5 | ? 1 6 | : 0; 7 | const branch2: boolean = true ? 1 : 0; 8 | const branch3: boolean = true || true || false; 9 | const fn: Function = true ? () => null : () => null; 10 | 11 | return a - b; 12 | } 13 | -------------------------------------------------------------------------------- /integration_tests/json_reporter/sum.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = function(a, b) { 10 | return a + b; 11 | }; 12 | -------------------------------------------------------------------------------- /integration_tests/setup_test_framework_script_file_cli_config/setup1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | global.definedInSetupFile = true; 10 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/mapped_module_test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = 'mapped_module'; 10 | -------------------------------------------------------------------------------- /packages/jest-snapshot/src/__tests__/plugins/bar.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | */ 9 | 'use strict'; 10 | 11 | module.exports = Symbol(); 12 | -------------------------------------------------------------------------------- /packages/jest-snapshot/src/__tests__/plugins/foo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | */ 9 | 'use strict'; 10 | 11 | module.exports = Symbol(); 12 | -------------------------------------------------------------------------------- /integration_tests/auto-clear-mocks/with-auto-clear/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | module.exports = () => {}; 12 | -------------------------------------------------------------------------------- /integration_tests/custom_reporters/add.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | */ 9 | 10 | 'use strict'; 11 | 12 | module.exports = (x, y) => x + y; 13 | -------------------------------------------------------------------------------- /integration_tests/test-in-root/foo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | // This test shouldn't run 10 | test('stub', () => expect(1).toBe(2)); 11 | -------------------------------------------------------------------------------- /integration_tests/test-in-root/spec.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | // This test should run 10 | test('stub', () => expect(1).toBe(1)); 11 | -------------------------------------------------------------------------------- /integration_tests/test-in-root/test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | // This test should run 10 | test('stub', () => expect(1).toBe(1)); 11 | -------------------------------------------------------------------------------- /integration_tests/transform/custom-instrumenting-preprocessor/src/some-other-file.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = {a: 1}; 10 | -------------------------------------------------------------------------------- /integration_tests/transform/multiple-transformers/jsPreprocessor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = require('babel-jest'); 10 | -------------------------------------------------------------------------------- /packages/jest-message-util/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-message-util", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "browser": "build-es5/index.js", 11 | "dependencies": { 12 | "chalk": "^1.1.3", 13 | "micromatch": "^2.3.11", 14 | "slash": "^1.0.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /integration_tests/auto-clear-mocks/without-auto-clear/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | module.exports = () => {}; 12 | -------------------------------------------------------------------------------- /integration_tests/test-in-root/footest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | // This test shouldn't run 10 | test('stub', () => expect(1).toBe(2)); 11 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/throwing.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | throw new Error('throwing'); 12 | -------------------------------------------------------------------------------- /integration_tests/empty_suite_error/__tests__/empty-suite-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | describe('sum', () => {}); 12 | -------------------------------------------------------------------------------- /integration_tests/coverage-remapping/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "rootDir": "./", 4 | "transform": { 5 | "^.+\\.(ts|js)$": "/typescript-preprocessor.js" 6 | }, 7 | "testRegex": "/__tests__/.*\\.(ts|tsx|js)$", 8 | "testEnvironment": "node", 9 | "moduleFileExtensions": [ 10 | "ts", 11 | "tsx", 12 | "js" 13 | ] 14 | }, 15 | "dependencies": { 16 | "typescript": "^1.8.10" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /integration_tests/typescript-coverage/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "rootDir": "./", 4 | "transform": { 5 | "^.+\\.(ts|js)$": "/typescript-preprocessor.js" 6 | }, 7 | "testMatch": ["**/__tests__/*.(ts|tsx|js)"], 8 | "testEnvironment": "node", 9 | "moduleFileExtensions": [ 10 | "ts", 11 | "tsx", 12 | "js" 13 | ] 14 | }, 15 | "dependencies": { 16 | "typescript": "^1.8.10" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/MyDirectoryModule/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.isIndex = true; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/haste-package/core/module.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.isHastePackage = true; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/module_dir/my-module/core.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.isNodeModule = true; 12 | -------------------------------------------------------------------------------- /integration_tests/failures/__tests__/throw-number-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | /* eslint-disable no-throw-literal */ 12 | throw 1; 13 | -------------------------------------------------------------------------------- /integration_tests/failures/__tests__/throw-object-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | /* eslint-disable no-throw-literal */ 12 | throw {}; 13 | -------------------------------------------------------------------------------- /integration_tests/setup_test_framework_script_file_cli_config/setup_hooks_into_runner.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | global.describeDefined = !!global.describe; 10 | -------------------------------------------------------------------------------- /integration_tests/testResultsProcessor/__tests__/processor-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | test('should match 1', () => expect(1).toBe(1)); 11 | -------------------------------------------------------------------------------- /integration_tests/transform/babel-jest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "babel-plugin-transform-flow-strip-types": "6.8.0" 4 | }, 5 | "jest": { 6 | "collectCoverageOnlyFrom": { 7 | "/this-directory-is-covered/covered.js": true, 8 | "/this-directory-is-covered/excluded-from-coverage.js": true 9 | }, 10 | "coveragePathIgnorePatterns": ["excluded-from-coverage"], 11 | "testEnvironment": "node" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/module_dir/moduleDirectoryFile.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.modulePath = 'invalid path'; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/UTF8WithBOM.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = 'isModuleEncodedInUTF8WithBOM'; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/internal-root.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = require('./internal-module'); 12 | -------------------------------------------------------------------------------- /integration_tests/stack_trace/__tests__/runtime-error-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | /* eslint-disable no-undef */ 11 | thisIsARuntimeError(); 12 | -------------------------------------------------------------------------------- /integration_tests/transform/custom-instrumenting-preprocessor/src/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | require('./some-other-file'); 10 | 11 | module.exports = {a: 1}; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/internal-module.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = () => 'internal-module-data'; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/node_modules/not-a-haste-package/core.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.isNodeModule = true; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/subdir2/module_dir/my-module/core.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.isNodeModule = true; 12 | -------------------------------------------------------------------------------- /packages/jest-validate/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-validate", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "browser": "build-es5/index.js", 11 | "dependencies": { 12 | "chalk": "^1.1.3", 13 | "jest-get-type": "^20.0.3", 14 | "leven": "^2.1.0", 15 | "pretty-format": "^20.0.3" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /integration_tests/failures/__tests__/throw-string-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | /* eslint-disable no-throw-literal */ 12 | throw 'banana'; 13 | -------------------------------------------------------------------------------- /integration_tests/babel-plugin-jest-hoist/mock-file.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | jest.mock('./banana', () => { 10 | const exports = 'apple'; 11 | return exports; 12 | }); 13 | -------------------------------------------------------------------------------- /packages/jest-jasmine2/src/__tests__/it_to_test_alias-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @emails oncall+jsinfra 9 | */ 10 | 'use strict'; 11 | 12 | test('global.test', () => {}); 13 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/MyModule.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.modulePath = 'subdir1/MyModule.js'; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/MyModule.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.modulePath = 'subdir2/MyModule.js'; 12 | -------------------------------------------------------------------------------- /integration_tests/testResultsProcessor/processor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = function(results) { 10 | results.processed = true; 11 | return results; 12 | }; 13 | -------------------------------------------------------------------------------- /packages/babel-jest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-jest", 3 | "description": "Jest plugin to use babel for transformation.", 4 | "version": "20.0.3", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/facebook/jest.git" 8 | }, 9 | "license": "BSD-3-Clause", 10 | "main": "build/index.js", 11 | "dependencies": { 12 | "babel-core": "^6.0.0", 13 | "babel-plugin-istanbul": "^4.0.0", 14 | "babel-preset-jest": "^20.0.3" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/jest-repl/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-repl", 3 | "version": "20.0.4", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "dependencies": { 11 | "jest-runtime": "^20.0.4", 12 | "jest-util": "^20.0.3", 13 | "repl": "^0.1.3", 14 | "yargs": "^7.0.2" 15 | }, 16 | "bin": { 17 | "jest-repl": "./bin/jest-repl.js" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/jest-resolve/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-resolve", 3 | "version": "20.0.4", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "dependencies": { 11 | "browser-resolve": "^1.11.2", 12 | "is-builtin-module": "^1.0.0", 13 | "resolve": "^1.3.2" 14 | }, 15 | "devDependencies": { 16 | "jest-haste-map": "^20.0.4" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/TestModuleNameMapperResolution.jsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.moduleNameMapperResolutionWorks = true; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/__mocks__/ExclusivelyManualMock.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.isExclusivelyManualMockModule = true; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/module_dir/moduleDirModule.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.modulePath = 'module_dir/moduleDirModule.js'; 12 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/java/com/jestrn/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.jestrn; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "jestrn"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /integration_tests/coverage_report/__mocks__/sum_dependency.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | // This is mock that does nothing but used for coverage integration test 11 | 12 | -------------------------------------------------------------------------------- /packages/jest-cli/src/__tests__/__snapshots__/watch-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Watch mode flows Runs Jest once by default and shows usage 1`] = ` 4 | Array [ 5 | " 6 | Watch Usage 7 | › Press o to only run tests related to changed files. 8 | › Press p to filter by a filename regex pattern. 9 | › Press t to filter by a test name regex pattern. 10 | › Press q to quit watch mode. 11 | › Press Enter to trigger a test run. 12 | ", 13 | ] 14 | `; 15 | -------------------------------------------------------------------------------- /packages/jest-jasmine2/src/ExpectationFailed.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | class ExpectationFailed extends Error {} 12 | 13 | module.exports = ExpectationFailed; 14 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/node_modules/npm3-transitive-dep/internal-code.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = () => 'internal-module-code'; 12 | -------------------------------------------------------------------------------- /types/Process.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | export interface Process { 12 | stdout: stream$Writable | tty$WriteStream, 13 | exit(code?: number): void, 14 | } 15 | -------------------------------------------------------------------------------- /integration_tests/regex-(char-in-path/__tests__/regex-(char-in-path.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | it('runs this', () => { 12 | expect(true).toBe(true); 13 | }); 14 | -------------------------------------------------------------------------------- /packages/jest-resolve/src/__mocks__/userResolver.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = function userResolver(path, options) { 12 | return 'module'; 13 | }; 14 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/platform/Platform.ios.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @providesModule Platform 9 | */ 10 | 11 | 'use strict'; 12 | 13 | exports.platform = 'ios'; 14 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/platform/Platform.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @providesModule Platform 9 | */ 10 | 11 | 'use strict'; 12 | 13 | exports.platform = 'default'; 14 | -------------------------------------------------------------------------------- /fixtures/nested_its.example: -------------------------------------------------------------------------------- 1 | describe('some context', () => { 2 | it('1', () => { 3 | }); 4 | it('2', () => { 5 | }); 6 | }); 7 | 8 | describe('some other context', () => { 9 | it('3', () => { 10 | }); 11 | }); 12 | 13 | describe('with old functions', function() { 14 | it('4', () => { 15 | }); 16 | }); 17 | 18 | fdescribe('with fdescribe', () => { 19 | it('5', () => { 20 | }); 21 | }); 22 | 23 | describe.only('with describe.only', () => { 24 | it('6', () => { 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /integration_tests/babel-plugin-jest-hoist/__test_modules__/Mocked.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | export default class Mocked { 10 | constructor() { 11 | this.isMocked = true; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /integration_tests/env-test/__tests__/env-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | console.log(global.window ? 'WINDOW' : 'NO WINDOW'); 11 | 12 | test('stub', () => expect(1).toBe(1)); 13 | -------------------------------------------------------------------------------- /integration_tests/snapshot-serializers/plugins/foo/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | */ 9 | 10 | const createPlugin = require('../../utils').createPlugin; 11 | module.exports = createPlugin('foo'); 12 | -------------------------------------------------------------------------------- /packages/jest-cli/bin/jest.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * Copyright (c) 2014, Facebook, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | if (process.env.NODE_ENV == null) { 11 | process.env.NODE_ENV = 'test'; 12 | } 13 | 14 | require('../build/cli').run(); 15 | -------------------------------------------------------------------------------- /packages/jest-resolve-dependencies/src/__tests__/__fixtures__/file.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | */ 9 | 'use strict'; 10 | 11 | require('jest-resolve-dependencies'); 12 | require('jest-regex-util'); 13 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/platform/Platform.android.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @providesModule Platform 9 | */ 10 | 11 | 'use strict'; 12 | 13 | exports.platform = 'android'; 14 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/platform/Platform.native.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @providesModule Platform 9 | */ 10 | 11 | 'use strict'; 12 | 13 | exports.platform = 'native'; 14 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/subdir2/module_dir/moduleDirModule.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.modulePath = 'subdir2/module_dir/moduleDirModule.js'; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/throwing-fn.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = function sum() { 12 | throw new Error('throwing fn'); 13 | }; 14 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/__mocks__/MyModule.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.modulePath = 'subdir1/__mocks__/MyModule.js'; 12 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/__mocks__/MyModule.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.modulePath = 'subdir2/__mocks__/MyModule.js'; 12 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | **Summary** 4 | 5 | 6 | 7 | **Test plan** 8 | 9 | 10 | -------------------------------------------------------------------------------- /integration_tests/babel-plugin-jest-hoist/__test_modules__/Unmocked.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | export default class Unmocked { 10 | constructor() { 11 | this.isUnmocked = true; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /integration_tests/snapshot-escape/__tests__/snapshot-escape-substitution-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | test('escape substitution', () => expect('${banana}').toMatchSnapshot()); 11 | -------------------------------------------------------------------------------- /integration_tests/snapshot-escape/__tests__/snapshot-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | // prettier-ignore 11 | test('escape strings', () => expect('one: \\\'').toMatchSnapshot()); 12 | -------------------------------------------------------------------------------- /packages/jest-diff/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-diff", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "browser": "build-es5/index.js", 11 | "dependencies": { 12 | "chalk": "^1.1.3", 13 | "diff": "^3.2.0", 14 | "jest-matcher-utils": "^20.0.3", 15 | "jest-get-type": "^20.0.3", 16 | "pretty-format": "^20.0.3" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/jest-haste-map/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-haste-map", 3 | "version": "20.0.4", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "dependencies": { 11 | "fb-watchman": "^2.0.0", 12 | "graceful-fs": "^4.1.11", 13 | "jest-docblock": "^20.0.3", 14 | "micromatch": "^2.3.11", 15 | "sane": "~1.6.0", 16 | "worker-farm": "^1.3.1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/jest-repl/bin/jest-repl.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * Copyright (c) 2014, Facebook, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | if (process.env.NODE_ENV == null) { 11 | process.env.NODE_ENV = 'test'; 12 | } 13 | 14 | require('../build/cli')(); 15 | -------------------------------------------------------------------------------- /packages/jest-resolve-dependencies/src/__tests__/__fixtures__/related-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | */ 9 | 'use strict'; 10 | 11 | test('sample', () => { 12 | expect({}).toMatchSnapshot(); 13 | }); 14 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/GlobalImageStub.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @providesModule GlobalImageStub 9 | */ 10 | 11 | 'use strict'; 12 | 13 | exports.isGlobalImageStub = true; 14 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/ManuallyMocked.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @providesModule ManuallyMocked 9 | */ 10 | 11 | 'use strict'; 12 | 13 | exports.isManualMockModule = false; 14 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/test-preprocessor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports.process = () => `throw new Error('preprocessor must not run.');`; 12 | -------------------------------------------------------------------------------- /examples/snapshot/__tests__/Clock.react-test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | /* eslint-disable no-unused-vars */ 3 | 4 | 'use strict'; 5 | 6 | import React from 'react'; 7 | import Clock from '../Clock.react'; 8 | import renderer from 'react-test-renderer'; 9 | 10 | jest.useFakeTimers(); 11 | Date.now = jest.fn(() => 1482363367071); 12 | 13 | it('renders correctly', () => { 14 | const tree = renderer.create().toJSON(); 15 | expect(tree).toMatchSnapshot(); 16 | }); 17 | -------------------------------------------------------------------------------- /integration_tests/__tests__/symbol-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | test('Symbol deletion', () => { 12 | global.Symbol = undefined; 13 | 14 | expect({}).toEqual({}); 15 | }); 16 | -------------------------------------------------------------------------------- /integration_tests/node_path/__tests__/node_path-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | test('can require by absolute path', () => { 11 | expect(require('path/file.js')).toBe(42); 12 | }); 13 | -------------------------------------------------------------------------------- /packages/jest-changed-files/src/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | import git from './git'; 12 | import hg from './hg'; 13 | 14 | module.exports = { 15 | git, 16 | hg, 17 | }; 18 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/module_dir/to-be-instrumented.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | const a = (b, c) => { 12 | return b + c; 13 | }; 14 | 15 | module.exports = {a}; 16 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/RelativeImageStub.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @providesModule RelativeImageStub 9 | */ 10 | 11 | 'use strict'; 12 | 13 | exports.isRelativeImageStub = true; 14 | -------------------------------------------------------------------------------- /packages/jest-snapshot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-snapshot", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "dependencies": { 11 | "chalk": "^1.1.3", 12 | "jest-diff": "^20.0.3", 13 | "jest-matcher-utils": "^20.0.3", 14 | "jest-util": "^20.0.3", 15 | "natural-compare": "^1.4.0", 16 | "pretty-format": "^20.0.3" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /website/core/center.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule center 3 | * @jsx React.DOM 4 | */ 5 | 6 | const React = require('React'); 7 | 8 | const assign = require('object-assign'); 9 | 10 | const center = React.createClass({ 11 | render() { 12 | const {style, ...props} = this.props; 13 | const newStyle = assign({}, style, {textAlign: 'center'}); 14 | 15 | return ( 16 |
{this.props.children}
17 | ); 18 | }, 19 | }); 20 | 21 | module.exports = center; 22 | -------------------------------------------------------------------------------- /integration_tests/stack_trace/__tests__/stack-trace-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | describe('stack trace', () => { 11 | it('fails', () => { 12 | expect(1).toBe(3); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /packages/jest-runtime/bin/jest-runtime.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * Copyright (c) 2014, Facebook, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | if (process.env.NODE_ENV == null) { 11 | process.env.NODE_ENV = 'test'; 12 | } 13 | 14 | require('../build/cli').run(); 15 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/module_dir/moduleDirModule.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | exports.modulePath = 'subdir2/module_dir/moduleDirModule.js'; 12 | -------------------------------------------------------------------------------- /website/src/jest/support.js: -------------------------------------------------------------------------------- 1 | /* This is a generated file */ 2 | const React = require('React'); 3 | const RedirectLayout = require('RedirectLayout'); 4 | class Support extends React.Component { 5 | render() { 6 | const metadata = { 7 | destinationUrl: 'help.html', 8 | id: 'support', 9 | layout: 'redirect', 10 | permalink: '/jest/support.html', 11 | source: 'support.md', 12 | }; 13 | return ; 14 | } 15 | } 16 | module.exports = Support; 17 | -------------------------------------------------------------------------------- /examples/timer/infiniteTimerGame.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | function infiniteTimerGame(callback) { 4 | console.log('Ready....go!'); 5 | 6 | setTimeout(() => { 7 | console.log('Times up! 10 seconds before the next game starts...'); 8 | callback && callback(); 9 | 10 | // Schedule the next game in 10 seconds 11 | setTimeout(() => { 12 | infiniteTimerGame(callback); 13 | }, 10000); 14 | }, 1000); 15 | } 16 | 17 | module.exports = infiniteTimerGame; 18 | -------------------------------------------------------------------------------- /packages/jest-circus/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-circus", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "dependencies": { 11 | "jest-snapshot": "^20.0.3", 12 | "jest-matchers": "^20.0.3", 13 | "jest-message-util": "^20.0.3", 14 | "jest-diff": "^20.0.3" 15 | }, 16 | "devDependencies": { 17 | "jest-runtime": "^20.0.3" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/OnlyRequiredFromMock.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @providesModule OnlyRequiredFromMock 9 | */ 10 | 11 | 'use strict'; 12 | 13 | exports.value = 'banana banana banana'; 14 | -------------------------------------------------------------------------------- /packages/pretty-format/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pretty-format", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "description": "Stringify any JavaScript value.", 10 | "main": "build/index.js", 11 | "browser": "build-es5/index.js", 12 | "author": "James Kyle ", 13 | "dependencies": { 14 | "ansi-regex": "^2.1.1", 15 | "ansi-styles": "^3.0.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /website/src/jest/en/support.js: -------------------------------------------------------------------------------- 1 | /* This is a generated file */ 2 | const React = require('React'); 3 | const RedirectLayout = require('RedirectLayout'); 4 | class Support extends React.Component { 5 | render() { 6 | const metadata = { 7 | destinationUrl: 'help.html', 8 | id: 'support', 9 | layout: 'redirect', 10 | permalink: '/jest/support.html', 11 | source: 'support.md', 12 | }; 13 | return ; 14 | } 15 | } 16 | module.exports = Support; 17 | -------------------------------------------------------------------------------- /packages/babel-preset-jest/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | module.exports = { 10 | plugins: [ 11 | // Cannot be `import` as this file is not compiled 12 | require('babel-plugin-jest-hoist'), 13 | ], 14 | }; 15 | -------------------------------------------------------------------------------- /packages/eslint-config-fb-strict/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-config-fb-strict", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "dependencies": { 10 | "babel-eslint": "^7.1.1", 11 | "eslint-config-fbjs": "^2.0.0-alpha.1", 12 | "eslint-plugin-babel": "^4.1.1", 13 | "eslint-plugin-jest": "^20.0.3" 14 | }, 15 | "peerDependencies": { 16 | "eslint": "^3.3.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | environment: 2 | matrix: 3 | - nodejs_version: "8" 4 | 5 | install: 6 | - ps: Install-Product node $env:nodejs_version x64 7 | - node --version 8 | - yarn --version 9 | - yarn install 10 | 11 | cache: 12 | - node_modules 13 | - .eslintcache 14 | 15 | test_script: 16 | - yarn run jest -- --color 17 | 18 | # Don't actually build. 19 | build: off 20 | 21 | notifications: 22 | - provider: Email 23 | on_build_success: false 24 | on_build_failure: false 25 | on_build_status_changed: false 26 | -------------------------------------------------------------------------------- /examples/jquery/fetchCurrentUser.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | const $ = require('jquery'); 4 | 5 | function parseJSON(user) { 6 | return { 7 | fullName: user.firstName + ' ' + user.lastName, 8 | loggedIn: true, 9 | }; 10 | } 11 | 12 | function fetchCurrentUser(callback) { 13 | return $.ajax({ 14 | success: user => callback(parseJSON(user)), 15 | type: 'GET', 16 | url: 'http://example.com/currentUser', 17 | }); 18 | } 19 | 20 | module.exports = fetchCurrentUser; 21 | -------------------------------------------------------------------------------- /integration_tests/__tests__/global-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @emails oncall+jsinfra 9 | */ 10 | 'use strict'; 11 | 12 | test('globals are properly defined', () => { 13 | expect(global.Object).toBe(Object); 14 | }); 15 | -------------------------------------------------------------------------------- /types/Reporters.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | import type {FS} from 'jest-haste-map'; 12 | 13 | export type ReporterOnStartOptions = {| 14 | estimatedTime: number, 15 | showStatus: boolean, 16 | |}; 17 | -------------------------------------------------------------------------------- /integration_tests/list_tests/__tests__/dummy-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | it("isn't actually run", () => { 12 | // (because it is only used for --listTests) 13 | expect(true).toBe(false); 14 | }); 15 | -------------------------------------------------------------------------------- /integration_tests/transform/no-babel-jest/__tests__/passes-with-no-babel-jest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | require('../this-directory-is-covered/excluded-from-coverage'); 12 | 13 | test('1', () => {}); 14 | -------------------------------------------------------------------------------- /packages/jest-matchers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-matchers", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "browser": "build-es5/index.js", 11 | "dependencies": { 12 | "jest-diff": "^20.0.3", 13 | "jest-get-type": "^20.0.3", 14 | "jest-matcher-utils": "^20.0.3", 15 | "jest-message-util": "^20.0.3", 16 | "jest-regex-util": "^20.0.3" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/jest-util/src/setGlobal.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | import type {Global} from 'types/Global'; 12 | 13 | module.exports = (global: Global, key: string, value: any) => 14 | (global[key] = value); 15 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/node_modules/conventional-changelog-core/.* 3 | .*/node_modules/fbjs/.* 4 | .*/node_modules/jest-validate/.* 5 | .*/node_modules/react-native/.* 6 | .*/vendor/jsonlint/.* 7 | .*/examples/.* 8 | .*/website/.* 9 | 10 | [options] 11 | module.name_mapper='^pretty-format$' -> '/packages/pretty-format/src/index.js' 12 | module.name_mapper='^types/\(.*\)$' -> '/types/\1.js' 13 | module.name_mapper='\(jest-[^/]*\)' -> '/packages/\1/src/index.js' 14 | 15 | [version] 16 | ^0.47.0 17 | -------------------------------------------------------------------------------- /examples/async/__mocks__/request.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const users = { 4 | 4: {name: 'Mark'}, 5 | 5: {name: 'Paul'}, 6 | }; 7 | 8 | export default function request(url) { 9 | return new Promise((resolve, reject) => { 10 | const userID = parseInt(url.substr('/users/'.length), 10); 11 | process.nextTick( 12 | () => 13 | users[userID] 14 | ? resolve(users[userID]) 15 | : reject({ 16 | error: 'User with ' + userID + ' not found.', 17 | }) 18 | ); 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /integration_tests/transform/babel-jest/not-covered.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | const thisFunctionIsNeverInstrumented = () => { 10 | return null; 11 | }; 12 | 13 | module.exports = { 14 | thisFunctionIsNeverInstrumented, 15 | }; 16 | -------------------------------------------------------------------------------- /integration_tests/typescript-coverage/typescript-preprocessor.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | const tsc = require('typescript'); 4 | 5 | module.exports = { 6 | process(src, path) { 7 | if (path.endsWith('.ts') || path.endsWith('.tsx')) { 8 | return tsc.transpile( 9 | src, 10 | { 11 | jsx: tsc.JsxEmit.React, 12 | module: tsc.ModuleKind.CommonJS, 13 | }, 14 | path, 15 | [] 16 | ); 17 | } 18 | return src; 19 | }, 20 | }; 21 | -------------------------------------------------------------------------------- /packages/jest-editor-support/README.md: -------------------------------------------------------------------------------- 1 | # jest-editor-support 2 | 3 | The engine that allows editors to build on top of Jest. 4 | 5 | ## Usage 6 | 7 | This is only useful if you are interested in building an editor integration for Jest. 8 | 9 | For now as an end user, I'd recommend looking at Orta's [vscode-jest](https://github.com/orta/vscode-jest/). 10 | 11 | ## Note 12 | Since version `18.2.0` TypeScript is now a peer dependency. 13 | If you don't need to handle `.tsx` files then you can safely ignore the warning during installation. 14 | -------------------------------------------------------------------------------- /integration_tests/transform/multiple-transformers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest": { 3 | "transform": { 4 | "^.+\\.css$": "/cssPreprocessor.js", 5 | "^.+\\.js$": "/jsPreprocessor.js", 6 | "^.+\\.svg$": "/filePreprocessor.js" 7 | }, 8 | "testEnvironment": "node" 9 | }, 10 | "dependencies": { 11 | "babel-preset-es2015": "^6.16.0", 12 | "babel-preset-react": "^6.16.0", 13 | "react": "^15.3.0", 14 | "react-dom": "^15.3.0", 15 | "react-test-renderer": "^15.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/jest-cli/src/lib/terminalUtils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | /* $FlowFixMe */ 12 | const getTerminalWidth = (): nubmer => process.stdout.columns; 13 | 14 | module.exports = { 15 | getTerminalWidth, 16 | }; 17 | -------------------------------------------------------------------------------- /packages/jest-haste-map/src/__tests__/hasteImpl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | module.exports = { 11 | getHasteName(path) { 12 | return path.substr(path.lastIndexOf('/') + 1).replace(/\.js$/, ''); 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /packages/jest-matcher-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-matcher-utils", 3 | "description": "A set of utility functions for jest-matchers and related packages", 4 | "version": "20.0.3", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/facebook/jest.git" 8 | }, 9 | "license": "BSD-3-Clause", 10 | "main": "build/index.js", 11 | "browser": "build-es5/index.js", 12 | "dependencies": { 13 | "chalk": "^1.1.3", 14 | "jest-get-type": "^20.0.3", 15 | "pretty-format": "^20.0.3" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/jest-resolve-dependencies/src/__tests__/__fixtures__/file-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | */ 9 | 'use strict'; 10 | 11 | const fileTest = require('./file'); 12 | 13 | test('sample', () => { 14 | expect(fileTest).toBeTruthy(); 15 | }); 16 | -------------------------------------------------------------------------------- /website/src/jest/img/favicon/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "icons": [ 4 | { 5 | "src": "/jest/img/favicon/android-chrome-192x192.png", 6 | "sizes": "192x192", 7 | "type": "image/png" 8 | }, 9 | { 10 | "src": "/jest/img/favicon/android-chrome-512x512.png", 11 | "sizes": "512x512", 12 | "type": "image/png" 13 | } 14 | ], 15 | "theme_color": "#99424f", 16 | "background_color": "#ffffff", 17 | "display": "standalone" 18 | } 19 | -------------------------------------------------------------------------------- /examples/react-native/ios/jestrn/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /integration_tests/coverage_report/sum_dependency.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | require('path'); 10 | 11 | const uncoveredFunction = () => { 12 | return true ? 1 + '5' : '999'; 13 | }; 14 | 15 | module.exports = { 16 | uncoveredFunction, 17 | }; 18 | -------------------------------------------------------------------------------- /packages/pretty-format/src/plugins/lib/escapeHTML.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | function escapeHTML(str: string): string { 12 | return str.replace(//g, '>'); 13 | } 14 | 15 | module.exports = escapeHTML; 16 | -------------------------------------------------------------------------------- /packages/jest-util/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-util", 3 | "version": "20.0.3", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "browser": "build-es5/index.js", 11 | "dependencies": { 12 | "chalk": "^1.1.3", 13 | "graceful-fs": "^4.1.11", 14 | "jest-message-util": "^20.0.3", 15 | "jest-mock": "^20.0.3", 16 | "jest-validate": "^20.0.3", 17 | "leven": "^2.1.0", 18 | "mkdirp": "^0.5.1" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /website/core/unindent.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule unindent 3 | */ 4 | 5 | // Remove the indentation introduced by JSX 6 | function unindent(code) { 7 | const lines = code.split('\n'); 8 | if (lines[0] === '') { 9 | lines.shift(); 10 | } 11 | if (lines.length <= 1) { 12 | return code; 13 | } 14 | 15 | const indent = lines[0].match(/^\s*/)[0]; 16 | for (let i = 0; i < lines.length; ++i) { 17 | lines[i] = lines[i].replace(new RegExp('^' + indent), ''); 18 | } 19 | return lines.join('\n'); 20 | } 21 | 22 | module.exports = unindent; 23 | -------------------------------------------------------------------------------- /examples/react-native/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-rn", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "start": "node node_modules/react-native/local-cli/cli.js start", 6 | "test": "jest" 7 | }, 8 | "dependencies": { 9 | "react": "15.4.2", 10 | "react-native": "^0.40.0" 11 | }, 12 | "devDependencies": { 13 | "babel-jest": "*", 14 | "babel-preset-env": "*", 15 | "babel-preset-react-native": "*", 16 | "jest": "*", 17 | "react-test-renderer": "*" 18 | }, 19 | "jest": { 20 | "preset": "react-native" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "react": "15.4.2", 4 | "react-dom": "15.4.2" 5 | }, 6 | "devDependencies": { 7 | "@types/jest": "^19.2.4", 8 | "jest": "*", 9 | "react-addons-test-utils": "15.4.2", 10 | "typescript": "*" 11 | }, 12 | "scripts": { 13 | "test": "jest" 14 | }, 15 | "jest": { 16 | "moduleFileExtensions": ["ts", "tsx", "js"], 17 | "transform": { 18 | "^.+\\.(ts|tsx)$": "/preprocessor.js" 19 | }, 20 | "testMatch": ["**/__tests__/*.(ts|tsx|js)"] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /integration_tests/snapshot-serializers/plugins/bar.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | */ 9 | 10 | /* eslint-disable no-unused-vars */ 11 | 12 | const createPlugin = require('../utils').createPlugin; 13 | 14 | // We inject the call to "createPlugin('bar') through the transformer" 15 | -------------------------------------------------------------------------------- /examples/async/request.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | const http = require('http'); 4 | 5 | export default function request(url) { 6 | return new Promise(resolve => { 7 | // This is an example of an http request, for example to fetch 8 | // user data from an API. 9 | // This module is being mocked in __mocks__/request.js 10 | http.get({path: url}, response => { 11 | let data = ''; 12 | response.on('data', _data => (data += _data)); 13 | response.on('end', () => resolve(data)); 14 | }); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /integration_tests/snapshot-serializers/utils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | */ 9 | 10 | exports.createPlugin = prop => { 11 | return { 12 | print: (val, serialize) => `${prop} - ${serialize(val[prop])}`, 13 | test: val => val && val.hasOwnProperty(prop), 14 | }; 15 | }; 16 | -------------------------------------------------------------------------------- /types/Resolve.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | import type _Resolver, { 12 | ResolveModuleConfig as _ResolveModuleConfig, 13 | } from 'jest-resolve'; 14 | 15 | export type Resolver = _Resolver; 16 | export type ResolveModuleConfig = _ResolveModuleConfig; 17 | -------------------------------------------------------------------------------- /integration_tests/set_immediate/__tests__/set-immediate-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | test('setImmediate test', () => { 12 | expect(true).toBe(true); 13 | 14 | setImmediate(() => { 15 | throw new Error('Scheduled Error'); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/jest-config/src/constants.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | import path from 'path'; 12 | 13 | exports.NODE_MODULES = path.sep + 'node_modules' + path.sep; 14 | exports.DEFAULT_JS_PATTERN = '^.+\\.jsx?$'; 15 | exports.DEFAULT_REPORTER_LABEL = 'default'; 16 | -------------------------------------------------------------------------------- /packages/jest-test-typescript-parser/src/__tests__/TypeScriptParser-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | const {parse} = require('../TypeScriptParser'); 12 | const {parserTests} = require('../../../../fixtures/parserTests'); 13 | 14 | parserTests(parse); 15 | -------------------------------------------------------------------------------- /packages/jest-util/src/clearLine.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | /* global stream$Writable */ 11 | 12 | module.exports = (stream: stream$Writable | tty$WriteStream) => { 13 | if (process.stdout.isTTY) { 14 | stream.write('\x1b[999D\x1b[K'); 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /integration_tests/setup_test_framework_script_file_cli_config/__tests__/test1-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | describe('test', () => { 11 | it('has predefined global variable', () => { 12 | expect(global.definedInSetupFile).toEqual(true); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /integration_tests/setup_test_framework_script_file_cli_config/__tests__/test2-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | describe('test', () => { 11 | it('has predefined global variable', () => { 12 | expect(global.definedInSetupFile).toEqual(true); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /packages/jest-editor-support/src/__tests__/parsers/BabylonParser-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | const {parse} = require('../../parsers/BabylonParser'); 12 | const {parserTests} = require('../../../../../fixtures/parserTests'); 13 | 14 | parserTests(parse); 15 | -------------------------------------------------------------------------------- /fixtures/global_its.example: -------------------------------------------------------------------------------- 1 | // @flow 2 | it('works with old functions', function() { 3 | 4 | }); 5 | 6 | it('works with new functions', () => { 7 | 8 | }); 9 | 10 | it('works with flow functions', () => { 11 | function foo(x: string): string { return x; } 12 | }); 13 | 14 | it('works with JSX', ()=> { 15 | const foo = () =>
; 16 | }) 17 | 18 | it.only('works with it.only', () => { 19 | 20 | }); 21 | 22 | fit('works with fit', () => { 23 | 24 | }); 25 | 26 | test('works with test', () => { 27 | 28 | }); 29 | 30 | test.only('works with test.only', () => { 31 | 32 | }); 33 | -------------------------------------------------------------------------------- /integration_tests/__tests__/require-v8-module-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @emails oncall+jsinfra 9 | */ 10 | 11 | test('v8 module', () => { 12 | expect(() => require('v8')).not.toThrow(); 13 | 14 | expect(require('v8').getHeapStatistics().total_heap_size).toBeDefined(); 15 | }); 16 | -------------------------------------------------------------------------------- /integration_tests/setup_test_framework_script_file_cli_config/__tests__/runner_patch-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | describe('setupFile', () => { 11 | it('patches jasmine in setup file', () => { 12 | expect(global.describeDefined).toBe(true); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /integration_tests/test-environment/__tests__/env-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @jest-environment jsdom 9 | */ 10 | 'use strict'; 11 | /* eslint-env browser*/ 12 | 13 | test('stub', () => { 14 | const element = document.createElement('div'); 15 | expect(element).not.toBeNull(); 16 | }); 17 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/logging.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | if (require('./RegularModule').getModuleStateValue()) { 12 | console.log('Hello, world!'); 13 | } else { 14 | console.log('Automocking is not properly disabled in jest-runtime.'); 15 | } 16 | -------------------------------------------------------------------------------- /integration_tests/transform/no-babel-jest/this-directory-is-covered/excluded-from-coverage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | require('./covered'); 10 | 11 | const thisFunctionIsNeverInstrumented = () => { 12 | return null; 13 | }; 14 | 15 | module.exports = { 16 | thisFunctionIsNeverInstrumented, 17 | }; 18 | -------------------------------------------------------------------------------- /packages/jest-cli/src/lib/colorize.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | import chalk from 'chalk'; 12 | 13 | module.exports = (str: string, start: number, end: number) => 14 | chalk.dim(str.slice(0, start)) + 15 | chalk.reset(str.slice(start, end)) + 16 | chalk.dim(str.slice(end)); 17 | -------------------------------------------------------------------------------- /website/core/Button.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @providesModule Button 3 | * @jsx React.DOM 4 | */ 5 | 6 | const React = require('React'); 7 | 8 | class Button extends React.Component { 9 | render() { 10 | return ( 11 | 20 | ); 21 | } 22 | } 23 | 24 | Button.defaultProps = { 25 | target: '_self', 26 | }; 27 | 28 | module.exports = Button; 29 | -------------------------------------------------------------------------------- /integration_tests/__tests__/resolve-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @emails oncall+jsinfra 9 | */ 10 | 'use strict'; 11 | 12 | const runJest = require('../runJest'); 13 | 14 | test('resolve platform modules', () => { 15 | const result = runJest('resolve'); 16 | expect(result.status).toBe(0); 17 | }); 18 | -------------------------------------------------------------------------------- /integration_tests/transform/multiple-transformers/filePreprocessor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | const path = require('path'); 10 | 11 | module.exports = { 12 | process(src, filename, config, options) { 13 | return ` 14 | module.exports = '${path.basename(filename)}'; 15 | `; 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /types/Mock.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | import type { 12 | MockFunctionMetadata as _MockFunctionMetadata, 13 | ModuleMocker as _ModuleMocker, 14 | } from 'jest-mock'; 15 | 16 | export type MockFunctionMetadata = _MockFunctionMetadata; 17 | export type ModuleMocker = _ModuleMocker; 18 | -------------------------------------------------------------------------------- /examples/react-native/ios/jestrn/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/eslint-plugin-jest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-plugin-jest", 3 | "version": "20.0.3", 4 | "description": "Eslint rules for Jest", 5 | "keywords": [ 6 | "eslint", 7 | "eslintplugin", 8 | "eslint-plugin" 9 | ], 10 | "author": { 11 | "name": "Jonathan Kim", 12 | "email": "hello@jkimbo.com", 13 | "url": "jkimbo.com" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/facebook/jest.git" 18 | }, 19 | "main": "build/index.js", 20 | "peerDependencies": { 21 | "eslint": ">=3.6" 22 | }, 23 | "license": "BSD-3-Clause" 24 | } 25 | -------------------------------------------------------------------------------- /packages/jest-jasmine2/src/__tests__/matchers-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @emails oncall+jsinfra 9 | */ 10 | 'use strict'; 11 | 12 | describe('matchers', () => { 13 | it('proxies matchers to jest-matchers', () => { 14 | expect(() => expect(1).toBe(2)).toThrowErrorMatchingSnapshot(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/haste-modules/FooRenderUtil.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @providesModule FooRenderUtil 9 | */ 10 | 11 | 'use strict'; 12 | 13 | module.exports = { 14 | getBodyHeight() { 15 | return 5; 16 | }, 17 | 18 | getHeaderHeight() { 19 | return 5; 20 | }, 21 | }; 22 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/node_modules/npm3-transitive-dep/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | const internalImplementation = require('./internal-code'); 12 | 13 | module.exports = () => 'npm3-transitive-dep'; 14 | module.exports.internalImplementation = internalImplementation; 15 | -------------------------------------------------------------------------------- /packages/jest-util/src/__tests__/__snapshots__/FakeTimers-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`FakeTimers runAllTimers warns when trying to advance timers while real timers are used 1`] = ` 4 | "A function to advance timers was called but the timers API is not mocked with fake timers. Call \`jest.useFakeTimers()\` in this test or enable fake timers globally by setting \`\\"timers\\": \\"fake\\"\` in the configuration file. This warning is likely a result of a default configuration change in Jest 15. 5 | 6 | Release Blog Post: https://facebook.github.io/jest/blog/2016/09/01/jest-15.html" 7 | `; 8 | -------------------------------------------------------------------------------- /integration_tests/transform/babel-jest/__tests__/babel-jest-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | require('../this-directory-is-covered/excluded-from-coverage'); 12 | 13 | it('strips flowtypes using babel-jest and .babelrc', () => { 14 | const a: string = 'a'; 15 | expect(a).toBe('a'); 16 | }); 17 | -------------------------------------------------------------------------------- /packages/jest-runtime/src/__tests__/test_root/ModuleWithSideEffects.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @providesModule ModuleWithSideEffects 9 | */ 10 | 11 | 'use strict'; 12 | 13 | const RegularModule = require('RegularModule'); 14 | 15 | RegularModule.setModuleStateValue('Side effect value'); 16 | 17 | exports.fn = () => '42'; 18 | -------------------------------------------------------------------------------- /types/Console.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | export type LogMessage = string; 12 | export type LogEntry = {| 13 | message: LogMessage, 14 | origin: string, 15 | type: LogType, 16 | |}; 17 | export type LogType = 'log' | 'info' | 'warn' | 'error'; 18 | export type ConsoleBuffer = Array; 19 | -------------------------------------------------------------------------------- /integration_tests/jasmine_async/__tests__/promise_xit-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | describe('promise xit', () => { 12 | xit('fails but will be skipped', () => { 13 | expect(true).toBe(false); 14 | }); 15 | 16 | it('will run', () => { 17 | return Promise.resolve(); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /integration_tests/snapshot-serializers/transformer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = { 12 | process(src, filename, config, options) { 13 | if (/bar.js$/.test(filename)) { 14 | return `${src};\nmodule.exports = createPlugin('bar');`; 15 | } 16 | return src; 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /integration_tests/timer-resetMocks/after_resetAllMocks/timer_and_mock.test.js: -------------------------------------------------------------------------------- 1 | describe('timers', () => { 2 | it('should work before calling resetAllMocks', () => { 3 | jest.useFakeTimers(); 4 | const f = jest.fn(); 5 | setImmediate(() => f()); 6 | jest.runAllImmediates(); 7 | expect(f.mock.calls.length).toBe(1); 8 | }); 9 | 10 | it('should not break after calling resetAllMocks', () => { 11 | jest.resetAllMocks(); 12 | jest.useFakeTimers(); 13 | const f = jest.fn(); 14 | setImmediate(() => f()); 15 | jest.runAllImmediates(); 16 | expect(f.mock.calls.length).toBe(1); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /packages/jest/README.md: -------------------------------------------------------------------------------- 1 | # Jest 2 | 3 | 🃏 Delightful JavaScript Testing 4 | 5 | - **👩🏻‍💻 Easy Setup**: Jest is a complete and easy to set up JavaScript testing solution. In fact, Jest works out of the box for any React project. 6 | 7 | - **🏃🏽 Instant Feedback**: Failed tests run first. Fast interactive mode can switch between running all tests or only test files related to changed files. 8 | 9 | - **📸 Snapshot Testing**: Jest can [capture snapshots](http://facebook.github.io/jest/docs/snapshot-testing.html) of React trees or other serializable values to simplify UI testing. 10 | 11 | Read More: http://facebook.github.io/jest/ 12 | -------------------------------------------------------------------------------- /examples/react-native/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IJ 26 | # 27 | *.iml 28 | .idea 29 | .gradle 30 | local.properties 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | 37 | # BUCK 38 | buck-out/ 39 | \.buckd/ 40 | android/app/libs 41 | android/keystores/debug.keystore 42 | -------------------------------------------------------------------------------- /integration_tests/__tests__/json-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | test('JSON is available in the global scope', () => { 11 | expect(JSON).toBe(global.JSON); 12 | }); 13 | 14 | test('JSON.parse creates objects from within this context', () => { 15 | expect(JSON.parse('{}').constructor).toBe(Object); 16 | }); 17 | -------------------------------------------------------------------------------- /integration_tests/transform/babel-jest/this-directory-is-covered/excluded-from-coverage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | require('./covered'); 10 | require('../not-covered'); 11 | 12 | const thisFunctionIsNeverInstrumented = () => { 13 | return null; 14 | }; 15 | 16 | module.exports = { 17 | thisFunctionIsNeverInstrumented, 18 | }; 19 | -------------------------------------------------------------------------------- /packages/jest-cli/README.md: -------------------------------------------------------------------------------- 1 | # Jest 2 | 3 | 🃏 Delightful JavaScript Testing 4 | 5 | - **👩🏻‍💻 Easy Setup**: Jest is a complete and easy to set up JavaScript testing solution. In fact, Jest works out of the box for any React project. 6 | 7 | - **🏃🏽 Instant Feedback**: Failed tests run first. Fast interactive mode can switch between running all tests or only test files related to changed files. 8 | 9 | - **📸 Snapshot Testing**: Jest can [capture snapshots](http://facebook.github.io/jest/docs/snapshot-testing.html) of React trees or other serializable values to simplify UI testing. 10 | 11 | Read More: http://facebook.github.io/jest/ 12 | -------------------------------------------------------------------------------- /integration_tests/jasmine_async/__tests__/concurrent-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | it.concurrent('one', () => Promise.resolve()); 12 | it.concurrent.skip('two', () => Promise.resolve()); 13 | it.concurrent('three', () => Promise.resolve()); 14 | it.concurrent('concurrent test fails', () => Promise.reject()); 15 | -------------------------------------------------------------------------------- /integration_tests/stack_trace/__tests__/stack-trace-without-message-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | test('fails with error without proper message', () => { 11 | const error = new Error('important message'); 12 | error.stack = error.stack.replace('Error: important message', 'Error '); 13 | throw error; 14 | }); 15 | -------------------------------------------------------------------------------- /integration_tests/coverage_report/sum.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | require('./sum_dependency.js'); 10 | require('./other-file'); 11 | 12 | const uncoveredFunction = () => { 13 | return 1 + 'abc'; 14 | }; 15 | 16 | const sum = (a, b) => { 17 | return a + b; 18 | }; 19 | 20 | module.exports = { 21 | sum, 22 | uncoveredFunction, 23 | }; 24 | -------------------------------------------------------------------------------- /integration_tests/testNamePattern/__tests__/testNamePattern-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | test('should match 1', () => expect(1).toBe(1)); 11 | test('should match 2', () => expect(1).toBe(1)); 12 | test('should not match 1', () => expect(1).toBe(1)); 13 | test.concurrent('should not match 2', () => expect(1).toBe(1)); 14 | -------------------------------------------------------------------------------- /examples/enzyme/__tests__/CheckboxWithLabel-test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | /* eslint-disable no-unused-vars */ 4 | 5 | import React from 'react'; 6 | import {shallow} from 'enzyme'; 7 | import CheckboxWithLabel from '../CheckboxWithLabel'; 8 | 9 | it('CheckboxWithLabel changes the text after click', () => { 10 | // Render a checkbox with label in the document 11 | const checkbox = shallow(); 12 | 13 | expect(checkbox.text()).toEqual('Off'); 14 | 15 | checkbox.find('input').simulate('change'); 16 | 17 | expect(checkbox.text()).toEqual('On'); 18 | }); 19 | -------------------------------------------------------------------------------- /integration_tests/json_reporter/__tests__/sum-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | const sum = require('../sum'); 11 | 12 | describe('sum', () => { 13 | it('adds numbers', () => { 14 | expect(sum(1, 2)).toEqual(3); 15 | }); 16 | 17 | it('fails the test', () => { 18 | expect(sum(1, 2)).toEqual(4); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/jest-message-util/src/__tests__/__snapshots__/messages-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`.formatExecError() 1`] = ` 4 | " ● Test suite failed to run 5 | 6 | Whoops! 7 | " 8 | `; 9 | 10 | exports[`should exclude jasmine from stack trace for Unix paths. 1`] = ` 11 | " Unix test 12 | 13 | at stack (../jest-jasmine2/build/jasmine-2.4.1.js:1580:17) 14 | 15 | at Object.addResult (../jest-jasmine2/build/jasmine-2.4.1.js:1550:14) 16 | at Object.it (build/__tests__/messages-test.js:45:41) 17 | " 18 | `; 19 | -------------------------------------------------------------------------------- /integration_tests/console/__tests__/console-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | test('works just fine', () => { 11 | console.log('This is a log message.'); 12 | 13 | console.info('This is an info message.'); 14 | 15 | console.warn('This is a warning message.'); 16 | 17 | console.error('This is an error message.'); 18 | }); 19 | -------------------------------------------------------------------------------- /integration_tests/custom_reporters/__tests__/add-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | */ 9 | 10 | 'use strict'; 11 | 12 | const add = require('../add'); 13 | 14 | describe('Custom Reporters', () => { 15 | test('adds ok', () => { 16 | expect(add(1, 2)).toBe(3); 17 | expect(add(3, 4)).toBe(7); 18 | expect(add(12, 24)).toBe(36); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /integration_tests/__tests__/__snapshots__/timeouts-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`does not exceed the timeout 1`] = ` 4 | " PASS __tests__/a-banana.js 5 | ✓ banana 6 | 7 | " 8 | `; 9 | 10 | exports[`does not exceed the timeout 2`] = ` 11 | "Test Suites: 1 passed, 1 total 12 | Tests: 1 passed, 1 total 13 | Snapshots: 0 total 14 | Time: <> 15 | Ran all test suites. 16 | " 17 | `; 18 | 19 | exports[`exceeds the timeout 1`] = ` 20 | "Test Suites: 1 failed, 1 total 21 | Tests: 1 failed, 1 total 22 | Snapshots: 0 total 23 | Time: <> 24 | Ran all test suites. 25 | " 26 | `; 27 | -------------------------------------------------------------------------------- /integration_tests/__tests__/node_path-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @emails oncall+jsinfra 9 | */ 10 | 'use strict'; 11 | 12 | const runJest = require('../runJest'); 13 | 14 | test('supports NODE_PATH', () => { 15 | const result = runJest('node_path', [], { 16 | nodePath: ['../node_path/src'], 17 | }); 18 | expect(result.status).toBe(0); 19 | }); 20 | -------------------------------------------------------------------------------- /integration_tests/custom_reporters/__tests__/add-fail-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | */ 9 | 10 | 'use strict'; 11 | 12 | const add = require('../add'); 13 | 14 | describe('CustomReporters', () => { 15 | test('adds fail', () => { 16 | expect(add(1, 3)).toBe(231); 17 | expect(add(5, 7)).toBe(120); 18 | expect(add(2, 4)).toBe(6); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/jest-util/src/NullConsole.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | * 8 | * @flow 9 | */ 10 | 11 | import Console from './Console'; 12 | 13 | class NullConsole extends Console { 14 | assert() {} 15 | dir() {} 16 | error() {} 17 | info() {} 18 | log() {} 19 | time() {} 20 | timeEnd() {} 21 | trace() {} 22 | warn() {} 23 | } 24 | 25 | module.exports = NullConsole; 26 | -------------------------------------------------------------------------------- /integration_tests/__tests__/__snapshots__/typescript-coverage-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`instruments and collects coverage for typescript files 1`] = ` 4 | "------------|----------|----------|----------|----------|----------------| 5 | File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines | 6 | ------------|----------|----------|----------|----------|----------------| 7 | All files | 100 | 100 | 100 | 100 | | 8 | covered.ts | 100 | 100 | 100 | 100 | | 9 | ------------|----------|----------|----------|----------|----------------| 10 | " 11 | `; 12 | -------------------------------------------------------------------------------- /integration_tests/verbose_reporter/__tests__/verbose-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 'use strict'; 9 | 10 | test('works just fine', () => { 11 | expect(1).toBe(1); 12 | }); 13 | 14 | test('does not work', () => { 15 | expect(1).toBe(2); 16 | }); 17 | 18 | describe('Verbose', () => { 19 | it('works', () => { 20 | expect('apple').toBe('apple'); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/jest-jasmine2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jest-jasmine2", 3 | "version": "20.0.4", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/facebook/jest.git" 7 | }, 8 | "license": "BSD-3-Clause", 9 | "main": "build/index.js", 10 | "dependencies": { 11 | "chalk": "^1.1.3", 12 | "graceful-fs": "^4.1.11", 13 | "jest-diff": "^20.0.3", 14 | "jest-matcher-utils": "^20.0.3", 15 | "jest-matchers": "^20.0.3", 16 | "jest-message-util": "^20.0.3", 17 | "jest-snapshot": "^20.0.3", 18 | "once": "^1.4.0", 19 | "p-map": "^1.1.1" 20 | }, 21 | "devDependencies": { 22 | "jest-runtime": "^20.0.4" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /integration_tests/transform/no-babel-jest/__tests__/fails-with-syntax-error-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. 3 | * 4 | * This source code is licensed under the BSD-style license found in the 5 | * LICENSE file in the root directory of this source tree. An additional grant 6 | * of patent rights can be found in the PATENTS file in the same directory. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | // fails because there is no `strip-flow-types` transform 12 | const thisFunctionIsNeverInstrumented = (a: string) => { 13 | return null; 14 | }; 15 | 16 | test('this is never called', () => { 17 | thisFunctionIsNeverInstrumented(); 18 | }); 19 | --------------------------------------------------------------------------------