Skip to content

Commit

Permalink
Optional file name
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread committed Dec 16, 2023
1 parent 6906deb commit 3887c61
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/document-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ function prepareWindow(window) {
}

/**
* @param {string} htmlFilePath
* @param {string} [htmlFilePath]
* @returns {import('vitest').TestAPI<{window: import('jsdom').DOMWindow}>}
*/
export function domTest(htmlFilePath) {
return test.extend({
// eslint-disable-next-line no-empty-pattern
window: async ({}, use) => {
const html = fs.readFileSync(htmlFilePath, {encoding: 'utf8'});
const html = typeof htmlFilePath === 'string' ? fs.readFileSync(htmlFilePath, {encoding: 'utf8'}) : '<!DOCTYPE html>';
const env = builtinEnvironments.jsdom;
const {teardown} = await env.setup(global, {jsdom: {html}});
const window = /** @type {import('jsdom').DOMWindow} */ (/** @type {unknown} */ (global.window));
Expand Down

0 comments on commit 3887c61

Please sign in to comment.