Skip to content

Commit f2e2003

Browse files
committed
fix random text coverage issue.
1 parent 166059b commit f2e2003

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

lib/__tests__/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,14 @@ describe("WebGL plugins", () => {
3232
const generatedCodeContent = (await import("./dist/test1.js")).getText();
3333
expect(fileContent).toBe(generatedCodeContent);
3434
});
35+
36+
test("throws error if no file is found", async ({ expect }) => {
37+
let didThrow = false;
38+
try {
39+
await esbuild.build({ ...buildOptions, entryPoints: [path.resolve(__dirname, "test2.ts")] });
40+
} catch (e) {
41+
didThrow = true;
42+
}
43+
expect(didThrow).toBe(true);
44+
});
3545
});

lib/__tests__/test2.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// test auto error
2+
3+
import text from "../src/my-file?raw";
4+
5+
export const getText = () => text;

lib/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ export const raw: (options?: RawPluginOptions) => Plugin = options => ({
4949
}
5050
if (!fs.existsSync(filePath))
5151
throw new Error(
52+
/* v8 ignore next */
5253
`File not found: ${args.pluginData}\nWe checked for following extensions: ${ext.join(", ")}. You can customise by passing {ext: [...]} to raw({ext:[...]})`,
54+
/* v8 ignore next */
5355
);
5456
return {
5557
contents: fs.readFileSync(filePath, "utf8"),

0 commit comments

Comments
 (0)