Skip to content
This repository has been archived by the owner on Sep 5, 2022. It is now read-only.

Commit

Permalink
test: simplify the use of puppeteer coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sebnitu committed Jul 15, 2020
1 parent 45dbb2a commit d02b915
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -22,6 +22,7 @@
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"test:integration": "jest && npm run cover:report",
"cover:report": "nyc report --reporter=lcov --reporter=text",
"unreleased": "conventional-changelog --outfile UNRELEASED.md --output-unreleased",
"preversion": "npm-run-all build lint test",
Expand Down Expand Up @@ -57,7 +58,7 @@
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"puppeteer": "^5.0.0",
"puppeteer-to-istanbul": "^1.4.0",
"puppeteer-to-istanbul": "^1.3.0",
"rollup": "^2.16.1",
"rollup-plugin-terser": "^6.1.0"
}
Expand Down
4 changes: 2 additions & 2 deletions tests/anchor.test.js
Expand Up @@ -4,13 +4,13 @@ import path from 'path';
import { throttleDelay } from './helpers/throttleDelay';

beforeAll(async () => {
await page.coverage.startJSCoverage({ resetOnNavigation: false });
await page.coverage.startJSCoverage();
await page.goto(`file:${path.join(__dirname, '../example.html')}`);
});

afterAll(async () => {
const jsCoverage = await page.coverage.stopJSCoverage();
pti.write(jsCoverage, { storagePath: './.nyc_output' });
pti.write(jsCoverage);
});

test('should scroll to anchor from initial scroll position', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/api.test.js
Expand Up @@ -11,7 +11,7 @@ let eLog = {
};

beforeAll(async () => {
await page.coverage.startJSCoverage({ resetOnNavigation: false });
await page.coverage.startJSCoverage();
await page.exposeFunction('onCustomEvent', ({ type, detail, target }) => {
if (type == 'scroll-stash:anchor') {
eLog.anchor.push({ type, detail, target });
Expand All @@ -34,7 +34,7 @@ beforeAll(async () => {

afterAll(async () => {
const jsCoverage = await page.coverage.stopJSCoverage();
pti.write(jsCoverage, { storagePath: './.nyc_output' });
pti.write(jsCoverage);
});

test('should scroll to anchor on showAnchor api call', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/events.test.js
Expand Up @@ -10,7 +10,7 @@ let eLog = {
};

beforeAll(async () => {
await page.coverage.startJSCoverage({ resetOnNavigation: false });
await page.coverage.startJSCoverage();
await page.exposeFunction('onCustomEvent', ({ type, detail, target }) => {
if (type == 'scroll-stash:anchor') {
eLog.anchor.push({ type, detail, target });
Expand Down Expand Up @@ -40,7 +40,7 @@ beforeAll(async () => {

afterAll(async () => {
const jsCoverage = await page.coverage.stopJSCoverage();
pti.write(jsCoverage, { storagePath: './.nyc_output' });
pti.write(jsCoverage);
});

test('should emit custom event when scroll states are saved', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/state.test.js
Expand Up @@ -6,7 +6,7 @@ import { throttleDelay } from './helpers/throttleDelay';
let maxScroll;

beforeAll(async () => {
await page.coverage.startJSCoverage({ resetOnNavigation: false });
await page.coverage.startJSCoverage();
await page.goto(`file:${path.join(__dirname, '../example.html')}`);
maxScroll = await page.$eval('#page', (el) => {
return (el.scrollHeight - el.offsetHeight);
Expand All @@ -15,7 +15,7 @@ beforeAll(async () => {

afterAll(async () => {
const jsCoverage = await page.coverage.stopJSCoverage();
pti.write(jsCoverage, { storagePath: './.nyc_output' });
pti.write(jsCoverage);
});

test('should save all scroll-stash elements to local storage', async () => {
Expand Down

0 comments on commit d02b915

Please sign in to comment.