workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

Reimplement dotenv.test.ts

Open rozenmd opened this issue 2 years ago • 0 comments

With unstable_dev, we deleted dotenv.test.ts. We should bring it back in a more useful form:

import { spawnWranglerDev } from "./helpers";

it("should use the environment variable from the .env file", async () => {
	const { wranglerProcess, fetchWhenReady, terminateProcess } =
		spawnWranglerDev("src/module.ts", "src/wrangler.dotenv.toml", 9002);

	try {
		await fetchWhenReady("http://localhost");
		expect(wranglerProcess.stdout?.read().toString()).toContain(
			"the value of foo"
		);
	} finally {
		await terminateProcess();
	}
});

rozenmd avatar Sep 01 '22 13:09 rozenmd