@vitest/browser 2.0.0-beta.7 → 2.0.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@
17
17
  })()
18
18
  </script>
19
19
  <!-- !LOAD_METADATA! -->
20
- <script type="module" crossorigin src="./assets/index-BNIf8EuF.js"></script>
20
+ <script type="module" crossorigin src="./assets/index-BZPCs_Bg.js"></script>
21
21
  <link rel="stylesheet" crossorigin href="./assets/index-DrQA2UkS.css">
22
22
  </head>
23
23
  <body>
package/dist/index.js CHANGED
@@ -2,11 +2,11 @@ import { fileURLToPath } from 'node:url';
2
2
  import { readFile as readFile$1 } from 'node:fs/promises';
3
3
  import { createRequire } from 'node:module';
4
4
  import sirv from 'sirv';
5
+ import { isFileServingAllowed, getFilePoolName, distDir } from 'vitest/node';
5
6
  import { coverageConfigDefaults } from 'vitest/config';
6
- import { slash } from '@vitest/utils';
7
+ import { slash, toArray } from '@vitest/utils';
7
8
  import fs, { promises } from 'node:fs';
8
9
  import { resolve as resolve$1, dirname as dirname$1 } from 'node:path';
9
- import { isFileServingAllowed } from 'vitest/node';
10
10
  import MagicString from 'magic-string';
11
11
  import { esmWalker } from '@vitest/utils/ast';
12
12
 
@@ -629,7 +629,7 @@ var index = (project, base = "/") => {
629
629
  }
630
630
  next();
631
631
  });
632
- let indexScripts;
632
+ let orchestratorScripts;
633
633
  let testerScripts;
634
634
  server.middlewares.use(async (req, res, next) => {
635
635
  if (!req.url)
@@ -648,9 +648,11 @@ var index = (project, base = "/") => {
648
648
  __VITEST_FILES__: JSON.stringify(files),
649
649
  __VITEST_TYPE__: url.pathname === base ? '"orchestrator"' : '"tester"'
650
650
  });
651
+ res.removeHeader("X-Frame-Options");
651
652
  if (url.pathname === base) {
652
- if (!indexScripts)
653
- indexScripts = await formatScripts(project.config.browser.indexScripts, server);
653
+ res.removeHeader("Content-Security-Policy");
654
+ if (!orchestratorScripts)
655
+ orchestratorScripts = await formatScripts(project.config.browser.orchestratorScripts, server);
654
656
  let baseHtml = await orchestratorHtml;
655
657
  if (project.config.browser.ui) {
656
658
  const manifestContent = await manifest;
@@ -667,13 +669,17 @@ var index = (project, base = "/") => {
667
669
  const html2 = replacer(baseHtml, {
668
670
  __VITEST_FAVICON__: favicon,
669
671
  __VITEST_TITLE__: "Vitest Browser Runner",
670
- __VITEST_SCRIPTS__: indexScripts,
672
+ __VITEST_SCRIPTS__: orchestratorScripts,
671
673
  __VITEST_INJECTOR__: injector
672
674
  });
673
675
  res.write(html2, "utf-8");
674
676
  res.end();
675
677
  return;
676
678
  }
679
+ const csp = res.getHeader("Content-Security-Policy");
680
+ if (typeof csp === "string") {
681
+ res.setHeader("Content-Security-Policy", csp.replace(/frame-ancestors [^;]+/, "frame-ancestors *"));
682
+ }
677
683
  const decodedTestFile = decodeURIComponent(url.pathname.slice(testerPrefix.length));
678
684
  const testFiles = await project.globTestFiles();
679
685
  const tests = decodedTestFile === "__vitest_all__" || !testFiles.includes(decodedTestFile) ? "__vitest_browser_runner__.files" : JSON.stringify([decodedTestFile]);
@@ -721,20 +727,37 @@ var index = (project, base = "/") => {
721
727
  name: "vitest:browser:tests",
722
728
  enforce: "pre",
723
729
  async config() {
730
+ const allTestFiles = await project.globTestFiles();
731
+ const browserTestFiles = allTestFiles.filter((file) => getFilePoolName(project, file) === "browser");
732
+ const setupFiles = toArray(project.config.setupFiles);
733
+ const vitestPaths = [
734
+ resolve(distDir, "index.js"),
735
+ resolve(distDir, "browser.js"),
736
+ resolve(distDir, "runners.js"),
737
+ resolve(distDir, "utils.js")
738
+ ];
724
739
  return {
725
740
  optimizeDeps: {
741
+ entries: [
742
+ ...browserTestFiles,
743
+ ...setupFiles,
744
+ ...vitestPaths
745
+ ],
726
746
  exclude: [
727
747
  "vitest",
728
748
  "vitest/utils",
729
749
  "vitest/browser",
730
750
  "vitest/runners",
731
751
  "@vitest/utils",
752
+ "@vitest/runner",
753
+ "@vitest/spy",
754
+ "@vitest/utils/error",
755
+ "@vitest/snapshot",
756
+ "@vitest/expect",
732
757
  "std-env",
733
758
  "tinybench",
734
759
  "tinyspy",
735
- "pathe",
736
- // loupe is manually transformed
737
- "loupe"
760
+ "pathe"
738
761
  ],
739
762
  include: [
740
763
  "vitest > @vitest/utils > pretty-format",
@@ -744,6 +767,7 @@ var index = (project, base = "/") => {
744
767
  "vitest > pretty-format > ansi-styles",
745
768
  "vitest > pretty-format > ansi-regex",
746
769
  "vitest > chai",
770
+ "vitest > chai > loupe",
747
771
  "vitest > @vitest/runner > p-limit",
748
772
  "vitest > @vitest/utils > diff-sequences",
749
773
  "@vitest/browser > @testing-library/user-event",
@@ -752,15 +776,6 @@ var index = (project, base = "/") => {
752
776
  }
753
777
  };
754
778
  },
755
- transform(code, id) {
756
- if (id.includes("loupe/loupe.js")) {
757
- const exportsList = ["custom", "inspect", "registerConstructor", "registerStringTag"];
758
- const codeAppend = exportsList.map((i) => `export const ${i} = globalThis.loupe.${i}`).join("\n");
759
- return `${code}
760
- ${codeAppend}
761
- export default globalThis.loupe`;
762
- }
763
- },
764
779
  async resolveId(id) {
765
780
  if (!/\?browserv=\w+$/.test(id))
766
781
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/browser",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.7",
4
+ "version": "2.0.0-beta.9",
5
5
  "description": "Browser running for Vitest",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -47,7 +47,7 @@
47
47
  "peerDependencies": {
48
48
  "playwright": "*",
49
49
  "webdriverio": "*",
50
- "vitest": "2.0.0-beta.7"
50
+ "vitest": "2.0.0-beta.9"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "playwright": {
@@ -65,7 +65,7 @@
65
65
  "@testing-library/user-event": "^14.5.2",
66
66
  "magic-string": "^0.30.10",
67
67
  "sirv": "^2.0.4",
68
- "@vitest/utils": "2.0.0-beta.7"
68
+ "@vitest/utils": "2.0.0-beta.9"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/ws": "^8.5.10",
@@ -77,10 +77,10 @@
77
77
  "playwright-core": "^1.44.0",
78
78
  "safaridriver": "^0.1.2",
79
79
  "webdriverio": "^8.36.1",
80
- "@vitest/ws-client": "2.0.0-beta.7",
81
- "vitest": "2.0.0-beta.7",
82
- "@vitest/runner": "2.0.0-beta.7",
83
- "@vitest/ui": "2.0.0-beta.7"
80
+ "@vitest/runner": "2.0.0-beta.9",
81
+ "@vitest/ui": "2.0.0-beta.9",
82
+ "vitest": "2.0.0-beta.9",
83
+ "@vitest/ws-client": "2.0.0-beta.9"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "rimraf dist && pnpm build:node && pnpm build:client",