From a126260a545e900b469640d945a39e47fb98f61a Mon Sep 17 00:00:00 2001 From: Tim Seckinger Date: Sat, 26 Jan 2019 00:48:23 +0100 Subject: [PATCH] e2e test running Jest programmatically --- e2e/__tests__/runProgramatically.test.js | 19 +++++++++++++++++++ e2e/run-programatically/index.js | 13 +++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 e2e/__tests__/runProgramatically.test.js create mode 100644 e2e/run-programatically/index.js diff --git a/e2e/__tests__/runProgramatically.test.js b/e2e/__tests__/runProgramatically.test.js new file mode 100644 index 000000000000..a9935672f962 --- /dev/null +++ b/e2e/__tests__/runProgramatically.test.js @@ -0,0 +1,19 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + */ + +import {resolve} from 'path'; + +import {run} from '../Utils'; + +const dir = resolve(__dirname, '..', 'run-programatically'); + +test('run Jest programatically', () => { + const {stdout} = run(`node index.js --version`, dir); + expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*-dev$/); +}); diff --git a/e2e/run-programatically/index.js b/e2e/run-programatically/index.js new file mode 100644 index 000000000000..a397521b7c74 --- /dev/null +++ b/e2e/run-programatically/index.js @@ -0,0 +1,13 @@ +#!/usr/bin/env node +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + */ + +// Running Jest like this is not officially supported, +// but it is common practice until there is a proper API as a substitute. +require('jest').run(process.argv);