mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-29 17:35:02 +08:00
Bug: 1300772 Change-Id: Ieb98b0517797b84e3499250e525d1fe76f76a674 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3735065 Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Auto-Submit: Danil Somsikov <dsv@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Danil Somsikov <dsv@chromium.org>
89 lines
2.4 KiB
TypeScript
89 lines
2.4 KiB
TypeScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import {assert} from 'chai';
|
|
|
|
import {
|
|
getBrowserAndPages,
|
|
getTestServerPort,
|
|
goToResource,
|
|
waitForElementWithTextContent,
|
|
} from '../../shared/helper.js';
|
|
import {describe, it} from '../../shared/mocha-extensions.js';
|
|
import {
|
|
clearCoverageContent,
|
|
getCoverageData,
|
|
navigateToCoverageTestSite,
|
|
startInstrumentingCoverage,
|
|
stopInstrumentingCoverage,
|
|
waitForTheCoveragePanelToLoad,
|
|
} from '../helpers/coverage-helpers.js';
|
|
|
|
describe('The Coverage Panel', async () => {
|
|
it('Loads correctly', async () => {
|
|
await waitForTheCoveragePanelToLoad();
|
|
});
|
|
|
|
it('Can start and stop instrumenting coverage', async () => {
|
|
await waitForTheCoveragePanelToLoad();
|
|
await navigateToCoverageTestSite();
|
|
await startInstrumentingCoverage();
|
|
await stopInstrumentingCoverage();
|
|
await clearCoverageContent();
|
|
});
|
|
|
|
it('Shows completly uncovered css files', async () => {
|
|
const {target} = getBrowserAndPages();
|
|
|
|
await goToResource('coverage/unused-css-coverage.html');
|
|
await waitForTheCoveragePanelToLoad();
|
|
await startInstrumentingCoverage();
|
|
const URL_PREFIX = `https://localhost:${getTestServerPort()}/test/e2e/resources/coverage`;
|
|
assert.deepEqual(await getCoverageData(5), [
|
|
{
|
|
'total': '283',
|
|
'unused': '276',
|
|
'url': `${URL_PREFIX}/unused-css-coverage.html`,
|
|
},
|
|
{
|
|
'total': '198',
|
|
'unused': '198',
|
|
'url': `${URL_PREFIX}/not-initially-used.css`,
|
|
},
|
|
{
|
|
'total': '196',
|
|
'unused': '196',
|
|
'url': `${URL_PREFIX}/unused.css`,
|
|
},
|
|
{
|
|
'total': '198',
|
|
'unused': '174',
|
|
'url': `${URL_PREFIX}/used.css`,
|
|
},
|
|
{
|
|
'total': '0',
|
|
'unused': '0',
|
|
'url': `${URL_PREFIX}/empty.css`,
|
|
},
|
|
]);
|
|
|
|
await target.evaluate('appendStylesheet()');
|
|
|
|
assert.deepInclude(await getCoverageData(6), {
|
|
'total': '0',
|
|
'unused': '0',
|
|
'url': `${URL_PREFIX}/lazily-loaded.css`,
|
|
});
|
|
|
|
await target.evaluate('appendElement()');
|
|
|
|
await waitForElementWithTextContent(`${URL_PREFIX}/not-initially-used.cssCSS198198100%`);
|
|
assert.deepInclude(await getCoverageData(6), {
|
|
'total': '198',
|
|
'unused': '198',
|
|
'url': `${URL_PREFIX}/not-initially-used.css`,
|
|
});
|
|
});
|
|
});
|