MCPcopy Create free account
hub / github.com/webpack/mini-css-extract-plugin / runInJsDom

Function runInJsDom

test/helpers/runInJsDom.js:11–44  ·  view source on GitHub ↗

* @param {string} assetName asset name * @param {Compiler} compiler compiler * @param {Stats} stats stats * @param {(dom: JSDOM, code: string) => void} testFn test function

(assetName, compiler, stats, testFn)

Source from the content-addressed store, hash-verified

9 * @param {(dom: JSDOM, code: string) => void} testFn test function
10 */
11function runInJsDom(assetName, compiler, stats, testFn) {
12 const bundle = readAsset(assetName, compiler, stats);
13 const virtualConsole = new jsdom.VirtualConsole();
14
15 virtualConsole.sendTo(console);
16
17 const dom = new jsdom.JSDOM(
18 `<!doctype html>
19<html>
20<head>
21 <title>style-loader test</title>
22 <style id="existing-style">.existing { color: yellow }</style>
23</head>
24<body>
25 <h1>Body</h1>
26 <div class="target"></div>
27 <iframe class='iframeTarget'></iframe>
28</body>
29</html>
30`,
31 {
32 resources: "usable",
33 runScripts: "dangerously",
34 virtualConsole,
35 },
36 );
37
38 dom.window.eval(bundle);
39
40 testFn(dom, bundle);
41
42 // free memory associated with the window
43 dom.window.close();
44}
45
46export default runInJsDom;

Callers 7

hooks.test.jsFile · 0.85
nonce.test.jsFile · 0.85

Calls 1

testFnFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…