Skip to content
/ jest Public
forked from jestjs/jest

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Jun 22, 2019
1 parent 9f9fb7d commit 917efc3
Show file tree
Hide file tree
Showing 18 changed files with 124,992 additions and 70 deletions.
7 changes: 7 additions & 0 deletions e2e/v8-coverage/__tests__/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

require('../typescript');

test('dummy test', () => {
expect(1).toBe(1);
});
5 changes: 5 additions & 0 deletions e2e/v8-coverage/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"jest": {
"testEnvironment": "node"
}
}
31 changes: 31 additions & 0 deletions e2e/v8-coverage/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const vm = require('vm');
const CoverageInstrumenter = require('@jest/coverage').default;

const script = new vm.Script(
`
function thing() {
if (Math.random() > 0.5) {
output = 'success!';
} else {
output = 'failure';
}
}
thing();
`
);

async function doThings() {
const context = vm.createContext({output: ''});
const instrumenter = new CoverageInstrumenter();

await instrumenter.startInstrumenting();

script.runInContext(context);

const coverage = await instrumenter.stopInstrumenting();

return JSON.stringify(coverage);
}

doThings().then(console.log, console.error);
Loading

0 comments on commit 917efc3

Please sign in to comment.