-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
243 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="icon" href="data:,"> | ||
<title>coverage page</title> | ||
<link href="../minify/style.css" rel="stylesheet" /> | ||
</head> | ||
|
||
<body> | ||
<h3 class="red inline-used and-used"> | ||
Mock V8 Rollup Coverage | ||
</h3> | ||
<script src="dist/coverage-rollup.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
var str: string = "hello world"; | ||
|
||
// point type | ||
type Point = { | ||
x: number, | ||
y: number | ||
} | ||
|
||
var p: Point = { | ||
x: 1, | ||
y: 2 | ||
} | ||
|
||
var fun = (v: Point) => { | ||
console.log(v); | ||
const fun = (p: Point, pointIn: Point) => { | ||
const str: string = "hello world"; | ||
console.log(p, pointIn, str); | ||
return str; | ||
} | ||
|
||
fun(p); | ||
|
||
var main = (p: Point, v: string) => { | ||
const main = (p: Point, s: string) => { | ||
/* | ||
block comment | ||
typescript block comment | ||
*/ | ||
const pointIn: Point = { | ||
x: 1, | ||
y: 2 | ||
} | ||
|
||
// typescript line comment | ||
|
||
const v = fun(p, pointIn); | ||
|
||
console.log(p, v); | ||
console.log(p, s, v); | ||
|
||
} | ||
|
||
module.exports = main; | ||
export default main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="icon" href="data:,"> | ||
<title>coverage page</title> | ||
<link href="../minify/style.css" rel="stylesheet" /> | ||
</head> | ||
|
||
<body> | ||
<h3 class="red inline-used and-used"> | ||
Mock V8 Vite Coverage | ||
</h3> | ||
<script src="dist/coverage-vite.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
const { chromium } = require('playwright'); | ||
const EC = require('eight-colors'); | ||
|
||
const CoverageReport = require('../'); | ||
|
||
const coverageOptions = { | ||
// logging: 'debug', | ||
reports: [ | ||
['v8', { | ||
name: 'My V8 Rollup Coverage Report', | ||
assetsPath: '../assets' | ||
}] | ||
], | ||
outputDir: './docs/v8-rollup' | ||
}; | ||
|
||
const test1 = async (serverUrl) => { | ||
|
||
console.log('start v8-rollup test1 ...'); | ||
const browser = await chromium.launch({ | ||
// headless: false | ||
}); | ||
const page = await browser.newPage(); | ||
|
||
await Promise.all([ | ||
page.coverage.startJSCoverage({ | ||
resetOnNavigation: false | ||
}), | ||
page.coverage.startCSSCoverage({ | ||
resetOnNavigation: false | ||
}) | ||
]); | ||
|
||
const url = `${serverUrl}/rollup/`; | ||
|
||
console.log(`goto ${url}`); | ||
|
||
await page.goto(url); | ||
|
||
await new Promise((resolve) => { | ||
setTimeout(resolve, 500); | ||
}); | ||
|
||
const [jsCoverage, cssCoverage] = await Promise.all([ | ||
page.coverage.stopJSCoverage(), | ||
page.coverage.stopCSSCoverage() | ||
]); | ||
|
||
const coverageList = [... jsCoverage, ... cssCoverage]; | ||
|
||
const results = await new CoverageReport(coverageOptions).add(coverageList); | ||
console.log('v8-rollup coverage1 added', results.type); | ||
|
||
await browser.close(); | ||
}; | ||
|
||
|
||
const test2 = async (serverUrl) => { | ||
|
||
console.log('start v8-rollup test2 ...'); | ||
const browser = await chromium.launch({ | ||
// headless: false | ||
}); | ||
const page = await browser.newPage(); | ||
|
||
await Promise.all([ | ||
page.coverage.startJSCoverage({ | ||
resetOnNavigation: false | ||
}), | ||
page.coverage.startCSSCoverage({ | ||
resetOnNavigation: false | ||
}) | ||
]); | ||
|
||
const url = `${serverUrl}/rollup/`; | ||
|
||
console.log(`goto ${url}`); | ||
|
||
await page.goto(url); | ||
|
||
await new Promise((resolve) => { | ||
setTimeout(resolve, 500); | ||
}); | ||
|
||
const [jsCoverage, cssCoverage] = await Promise.all([ | ||
page.coverage.stopJSCoverage(), | ||
page.coverage.stopCSSCoverage() | ||
]); | ||
|
||
const coverageList = [... jsCoverage, ... cssCoverage]; | ||
|
||
const results = await new CoverageReport(coverageOptions).add(coverageList); | ||
console.log('v8-rollup coverage2 added', results.type); | ||
|
||
await browser.close(); | ||
}; | ||
|
||
|
||
const generate = async () => { | ||
|
||
console.log('generate v8-rollup coverage reports ...'); | ||
|
||
const coverageResults = await new CoverageReport(coverageOptions).generate(); | ||
console.log('reportPath', EC.magenta(coverageResults.reportPath)); | ||
|
||
console.log('v8-rollup coverage generated', coverageResults.summary); | ||
}; | ||
|
||
|
||
module.exports = async (serverUrl) => { | ||
// clean cache first if debug | ||
if (coverageOptions.logging === 'debug') { | ||
await new CoverageReport(coverageOptions).cleanCache(); | ||
} | ||
|
||
await Promise.all([ | ||
test1(serverUrl), | ||
test2(serverUrl) | ||
]); | ||
|
||
await generate(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters