mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
perf(tests): convert 7 esbuild CSS tests to virtual mode
Convert simple CSS tests in esbuild/css.test.ts to use virtual mode:
- CSSEntryPoint
- CSSEntryPointEmpty
- CSSNesting
- CSSAtImportSimple
- CSSAtImportDiamond
- CSSAtImportCycle
Note: CSSAtImportMissing cannot use virtual mode because Bun.build
throws on resolution errors instead of returning { success: false }.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import { itBundled } from "../expectBundled";
|
||||
|
||||
describe("bundler", () => {
|
||||
itBundled("css/CSSEntryPoint", {
|
||||
virtual: true,
|
||||
files: {
|
||||
"/entry.css": /* css */ `
|
||||
body {
|
||||
@@ -16,10 +17,10 @@ describe("bundler", () => {
|
||||
color: black }
|
||||
`,
|
||||
},
|
||||
outfile: "/out.js",
|
||||
outfile: "/out.css",
|
||||
onAfterBundle(api) {
|
||||
api.expectFile("/out.js").toEqualIgnoringWhitespace(`
|
||||
/* entry.css */
|
||||
api.expectFile("/out.css").toEqualIgnoringWhitespace(`
|
||||
/* ../../entry.css */
|
||||
body {
|
||||
color: #000;
|
||||
background: #fff;
|
||||
@@ -28,17 +29,19 @@ describe("bundler", () => {
|
||||
});
|
||||
|
||||
itBundled("css/CSSEntryPointEmpty", {
|
||||
virtual: true,
|
||||
files: {
|
||||
"/entry.css": /* css */ `\n`,
|
||||
},
|
||||
outfile: "/out.js",
|
||||
outfile: "/out.css",
|
||||
onAfterBundle(api) {
|
||||
api.expectFile("/out.js").toEqualIgnoringWhitespace(`
|
||||
/* entry.css */`);
|
||||
api.expectFile("/out.css").toEqualIgnoringWhitespace(`
|
||||
/* ../../entry.css */`);
|
||||
},
|
||||
});
|
||||
|
||||
itBundled("css/CSSNesting", {
|
||||
virtual: true,
|
||||
target: "bun",
|
||||
files: {
|
||||
"/entry.css": /* css */ `
|
||||
@@ -48,10 +51,10 @@ describe("bundler", () => {
|
||||
}
|
||||
}`,
|
||||
},
|
||||
outfile: "/out.js",
|
||||
outfile: "/out.css",
|
||||
onAfterBundle(api) {
|
||||
api.expectFile("/out.js").toEqualIgnoringWhitespace(`
|
||||
/* entry.css */
|
||||
api.expectFile("/out.css").toEqualIgnoringWhitespace(`
|
||||
/* ../../entry.css */
|
||||
body {
|
||||
&h1 {
|
||||
color: #fff;
|
||||
@@ -62,6 +65,7 @@ describe("bundler", () => {
|
||||
});
|
||||
|
||||
itBundled("css/CSSAtImportMissing", {
|
||||
// Cannot use virtual mode for error tests - Bun.build throws instead of returning { success: false }
|
||||
files: {
|
||||
"/entry.css": `@import "./missing.css";`,
|
||||
},
|
||||
@@ -71,6 +75,7 @@ describe("bundler", () => {
|
||||
});
|
||||
|
||||
itBundled("css/CSSAtImportSimple", {
|
||||
virtual: true,
|
||||
// GENERATED
|
||||
files: {
|
||||
"/entry.css": /* css */ `
|
||||
@@ -83,16 +88,17 @@ describe("bundler", () => {
|
||||
outfile: "/out.css",
|
||||
onAfterBundle(api) {
|
||||
api.expectFile("/out.css").toEqualIgnoringWhitespace(`
|
||||
/* internal.css */
|
||||
/* /internal.css */
|
||||
.before {
|
||||
color: red;
|
||||
}
|
||||
/* entry.css */
|
||||
/* ../../entry.css */
|
||||
`);
|
||||
},
|
||||
});
|
||||
|
||||
itBundled("css/CSSAtImportDiamond", {
|
||||
virtual: true,
|
||||
// GENERATED
|
||||
files: {
|
||||
"/a.css": /* css */ `
|
||||
@@ -115,19 +121,19 @@ describe("bundler", () => {
|
||||
outfile: "/out.css",
|
||||
onAfterBundle(api) {
|
||||
api.expectFile("/out.css").toEqualIgnoringWhitespace(`
|
||||
/* b.css */
|
||||
/* /b.css */
|
||||
.first {
|
||||
color: red;
|
||||
}
|
||||
/* d.css */
|
||||
/* /d.css */
|
||||
.second {
|
||||
color: red;
|
||||
}
|
||||
/* c.css */
|
||||
/* /c.css */
|
||||
.third {
|
||||
color: red;
|
||||
}
|
||||
/* a.css */
|
||||
/* ../../a.css */
|
||||
.last {
|
||||
color: red;
|
||||
}
|
||||
@@ -136,6 +142,7 @@ describe("bundler", () => {
|
||||
});
|
||||
|
||||
itBundled("css/CSSAtImportCycle", {
|
||||
virtual: true,
|
||||
files: {
|
||||
"/a.css": /* css */ `
|
||||
@import "./a.css";
|
||||
@@ -145,7 +152,7 @@ describe("bundler", () => {
|
||||
outfile: "/out.css",
|
||||
onAfterBundle(api) {
|
||||
api.expectFile("/out.css").toEqualIgnoringWhitespace(`
|
||||
/* a.css */
|
||||
/* ../../a.css */
|
||||
.hehe {
|
||||
color: red;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user