|
1 |
| -import { execa, execaNode } from "execa"; |
| 1 | +import { execa } from "execa"; |
2 | 2 | import { readFileSync } from "node:fs";
|
3 | 3 | import { rename, rm } from "node:fs/promises";
|
4 | 4 | import { join, resolve } from "node:path";
|
5 | 5 |
|
6 | 6 | import { typecheckProject } from "../src/commands/deploy";
|
7 |
| -import { readConfig } from "../src/utilities/configFiles"; |
| 7 | +import { readConfig, ReadConfigFileResult } from "../src/utilities/configFiles"; |
8 | 8 | import { compile } from "./compile";
|
9 | 9 | import { Metafile } from "esbuild";
|
10 | 10 | import { Loglevel, LogLevelSchema, PackageManager, PackageManagerSchema } from ".";
|
|
52 | 52 | if (testCases.length > 0) {
|
53 | 53 | console.log(`Using ${packageManager}`);
|
54 | 54 |
|
55 |
| - describe.each(testCases)("fixture $name", async ({ name, skipTypecheck }) => { |
| 55 | + describe.each(testCases)("fixture $name", async ({ name, skipTypecheck }: TestCase) => { |
56 | 56 | const fixtureDir = resolve(join(process.cwd(), "e2e/fixtures", name));
|
57 |
| - const resolvedConfig = await readConfig(fixtureDir, { cwd: fixtureDir }); |
58 |
| - |
59 |
| - if (resolvedConfig.status === "error") { |
60 |
| - throw new Error(`cannot resolve config in directory ${fixtureDir}`); |
61 |
| - } |
62 | 57 |
|
63 | 58 | beforeAll(async () => {
|
64 | 59 | await rm(resolve(join(fixtureDir, ".trigger")), { force: true, recursive: true });
|
@@ -109,32 +104,47 @@ if (testCases.length > 0) {
|
109 | 104 | { timeout: 60_000 }
|
110 | 105 | );
|
111 | 106 |
|
112 |
| - if (!skipTypecheck) { |
113 |
| - test("typechecks", async () => { |
| 107 | + test("resolves config", async () => { |
| 108 | + await expect( |
| 109 | + (async () => { |
| 110 | + global.resolvedConfig = await readConfig(fixtureDir, { cwd: fixtureDir }); |
| 111 | + })() |
| 112 | + ).resolves.not.toThrowError(); |
| 113 | + |
| 114 | + expect(global.resolvedConfig).not.toBe("error"); |
| 115 | + }); |
| 116 | + |
| 117 | + describe("with resolved config", () => { |
| 118 | + test.skipIf(skipTypecheck)("typechecks", async () => { |
| 119 | + expect(global.resolvedConfig.status).not.toBe("error"); |
| 120 | + |
114 | 121 | await expect(
|
115 |
| - (async () => await typecheckProject(resolvedConfig.config))() |
| 122 | + (async () => |
| 123 | + await typecheckProject((global.resolvedConfig as ReadConfigFileResult).config))() |
116 | 124 | ).resolves.not.toThrowError();
|
117 | 125 | });
|
118 |
| - } |
119 | 126 |
|
120 |
| - let entrypointMetadata: Metafile["outputs"]["out/stdin.js"]; |
121 |
| - let workerMetadata: Metafile["outputs"]["out/stdin.js"]; |
| 127 | + let entrypointMetadata: Metafile["outputs"]["out/stdin.js"]; |
| 128 | + let workerMetadata: Metafile["outputs"]["out/stdin.js"]; |
122 | 129 |
|
123 |
| - test( |
124 |
| - "compiles", |
125 |
| - async () => { |
126 |
| - await expect( |
127 |
| - (async () => { |
128 |
| - const { entryPointMetaOutput, metaOutput } = await compile({ |
129 |
| - resolvedConfig, |
130 |
| - }); |
131 |
| - entrypointMetadata = entryPointMetaOutput; |
132 |
| - workerMetadata = metaOutput; |
133 |
| - })() |
134 |
| - ).resolves.not.toThrowError(); |
135 |
| - }, |
136 |
| - { timeout: 60_000 } |
137 |
| - ); |
| 130 | + test( |
| 131 | + "compiles", |
| 132 | + async () => { |
| 133 | + expect(global.resolvedConfig.status).not.toBe("error"); |
| 134 | + |
| 135 | + await expect( |
| 136 | + (async () => { |
| 137 | + const { entryPointMetaOutput, metaOutput } = await compile({ |
| 138 | + resolvedConfig: global.resolvedConfig, |
| 139 | + }); |
| 140 | + entrypointMetadata = entryPointMetaOutput; |
| 141 | + workerMetadata = metaOutput; |
| 142 | + })() |
| 143 | + ).resolves.not.toThrowError(); |
| 144 | + }, |
| 145 | + { timeout: 60_000 } |
| 146 | + ); |
| 147 | + }); |
138 | 148 | });
|
139 | 149 | } else if (process.env.MOD) {
|
140 | 150 | throw new Error(`Unknown fixture '${process.env.MOD}'`);
|
|
0 commit comments