Skip to content

Instantly share code, notes, and snippets.

@another-guy
Created March 4, 2019 09:24
Show Gist options
  • Save another-guy/349d2c3c78ab4d4f44aba7f2f5de2907 to your computer and use it in GitHub Desktop.
Save another-guy/349d2c3c78ab4d4f44aba7f2f5de2907 to your computer and use it in GitHub Desktop.
Jest Test runner working code
import { runCLI } from 'jest-cli';
const path = require('path');
const jestTestRunnerForVSCodeE2E: ITestRunner = {
run(testsRoot: string, reportTestResults: (error: Error, failures?: number) => void): void {
const projectRootPath = path.join(process.cwd(), '../..');
const config = path.join(projectRootPath, 'jest.e2e.config.js');
runCLI({ config } as any, [projectRootPath])
.then(jestCliCallResult => {
reportTestResults(undefined, jestCliCallResult.results.numFailedTests);
})
.catch(errorCaughtByJestRunner => {
reportTestResults(errorCaughtByJestRunner, 0);
});
}
};
module.exports = jestTestRunnerForVSCodeE2E;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment