Socket
Socket
Sign inDemoInstall

@vitest/browser

Package Overview
Dependencies
Maintainers
4
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vitest/browser - npm Package Compare versions

Comparing version 1.5.3 to 1.6.0

dist/client/__vitest__/assets/index-TpLatVz2.js

78

dist/index.js

@@ -5,2 +5,3 @@ import { fileURLToPath } from 'node:url';

import { coverageConfigDefaults } from 'vitest/config';
import { slash } from '@vitest/utils';
import MagicString from 'magic-string';

@@ -15,3 +16,54 @@ import { esmWalker } from '@vitest/utils/ast';

}
const _UNC_REGEX = /^[/\\]{2}/;
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
const normalize = function(path) {
if (path.length === 0) {
return ".";
}
path = normalizeWindowsPath(path);
const isUNCPath = path.match(_UNC_REGEX);
const isPathAbsolute = isAbsolute(path);
const trailingSeparator = path[path.length - 1] === "/";
path = normalizeString(path, !isPathAbsolute);
if (path.length === 0) {
if (isPathAbsolute) {
return "/";
}
return trailingSeparator ? "./" : ".";
}
if (trailingSeparator) {
path += "/";
}
if (_DRIVE_LETTER_RE.test(path)) {
path += "/";
}
if (isUNCPath) {
if (!isPathAbsolute) {
return `//./${path}`;
}
return `//${path}`;
}
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
};
const join = function(...arguments_) {
if (arguments_.length === 0) {
return ".";
}
let joined;
for (const argument of arguments_) {
if (argument && argument.length > 0) {
if (joined === void 0) {
joined = argument;
} else {
joined += `/${argument}`;
}
}
}
if (joined === void 0) {
return ".";
}
return normalize(joined.replace(/\/\/+/g, "/"));
};
function cwd() {

@@ -350,5 +402,2 @@ if (typeof process !== "undefined") {

function replacer(code, values) {
return code.replace(/{\s*(\w+)\s*}/g, (_, key) => values[key] ?? "");
}
var index = (project, base = "/") => {

@@ -382,2 +431,4 @@ const pkgRoot = resolve(fileURLToPath(import.meta.url), "../..");

});
let indexScripts;
let testerScripts;
server.middlewares.use(async (req, res, next) => {

@@ -400,5 +451,8 @@ if (!req.url)

if (url.pathname === base) {
if (!indexScripts)
indexScripts = await formatScripts(project.config.browser.indexScripts, server);
const html2 = replacer(await runnerHtml, {
__VITEST_FAVICON__: favicon,
__VITEST_TITLE__: "Vitest Browser Runner",
__VITEST_SCRIPTS__: indexScripts,
__VITEST_INJECTOR__: injector

@@ -412,5 +466,8 @@ });

const tests = decodedTestFile === "__vitest_all__" || !files.includes(decodedTestFile) ? "__vitest_browser_runner__.files" : JSON.stringify([decodedTestFile]);
if (!testerScripts)
testerScripts = await formatScripts(project.config.browser.testerScripts, server);
const html = replacer(await testerHtml, {
__VITEST_FAVICON__: favicon,
__VITEST_TITLE__: "Vitest Browser Tester",
__VITEST_SCRIPTS__: testerScripts,
__VITEST_INJECTOR__: injector,

@@ -550,3 +607,18 @@ __VITEST_APPEND__: (

}
function replacer(code, values) {
return code.replace(/{\s*(\w+)\s*}/g, (_, key) => values[key] ?? "");
}
async function formatScripts(scripts, server) {
if (!scripts?.length)
return "";
const promises = scripts.map(async ({ content, src, async, id, type = "module" }, index) => {
const srcLink = (src ? (await server.pluginContainer.resolveId(src))?.id : void 0) || src;
const transformId = srcLink || join(server.config.root, `virtual__${id || `injected-${index}.js`}`);
await server.moduleGraph.ensureEntryFromUrl(transformId);
const contentProcessed = content && type === "module" ? (await server.pluginContainer.transform(content, transformId)).code : content;
return `<script type="${type}"${async ? " async" : ""}${srcLink ? ` src="${slash(`/@fs/${srcLink}`)}"` : ""}>${contentProcessed || ""}<\/script>`;
});
return (await Promise.all(promises)).join("\n");
}
export { index as default };

14

package.json
{
"name": "@vitest/browser",
"type": "module",
"version": "1.5.3",
"version": "1.6.0",
"description": "Browser running for Vitest",

@@ -46,3 +46,3 @@ "license": "MIT",

"webdriverio": "*",
"vitest": "1.5.3"
"vitest": "1.6.0"
},

@@ -63,3 +63,3 @@ "peerDependenciesMeta": {

"sirv": "^2.0.4",
"@vitest/utils": "1.5.3"
"@vitest/utils": "1.6.0"
},

@@ -74,6 +74,6 @@ "devDependencies": {

"webdriverio": "^8.32.2",
"@vitest/ui": "1.5.3",
"@vitest/runner": "1.5.3",
"@vitest/ws-client": "1.5.3",
"vitest": "1.5.3"
"@vitest/runner": "1.6.0",
"@vitest/ui": "1.6.0",
"@vitest/ws-client": "1.6.0",
"vitest": "1.6.0"
},

@@ -80,0 +80,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc