Skip to content

Commit 203ffe7

Browse files
codenemericallam
authored andcommitted
Add fixtures for config step
1 parent e01bfd0 commit 203ffe7

30 files changed

+167
-12
lines changed

packages/cli-v3/e2e/fixtures/no-config/package-lock.json renamed to packages/cli-v3/e2e/fixtures/config-invalid/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli-v3/e2e/fixtures/no-config/package.json renamed to packages/cli-v3/e2e/fixtures/config-invalid/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "no-config",
2+
"name": "config-invalid",
33
"private": true,
44
"packageManager": "[email protected]+sha256.4b4efa12490e5055d59b9b9fc9438b7d581a6b7af3b5675eb5c5f447cee1a589",
55
"engines": {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const config = {
2+
// 'project' field is mandatory
3+
triggerDirectories: [],
4+
};

packages/cli-v3/e2e/fixtures/no-config/yarn.lock renamed to packages/cli-v3/e2e/fixtures/config-invalid/yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ __metadata:
55
version: 8
66
cacheKey: 10c0
77

8-
"no-config@workspace:.":
8+
"config-invalid@workspace:.":
99
version: 0.0.0-use.local
10-
resolution: "no-config@workspace:."
10+
resolution: "config-invalid@workspace:."
1111
languageName: unknown
1212
linkType: soft
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

packages/cli-v3/e2e/fixtures/config-not-found/package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "config-not-found",
3+
"private": true,
4+
"packageManager": "[email protected]+sha256.4b4efa12490e5055d59b9b9fc9438b7d581a6b7af3b5675eb5c5f447cee1a589",
5+
"engines": {
6+
"pnpm": "8.15.5",
7+
"yarn": "4.2.2"
8+
}
9+
}

packages/cli-v3/e2e/fixtures/config-not-found/pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# https://github.com/pnpm/pnpm/issues/2412
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is generated by running "yarn install" inside your project.
2+
# Manual changes might be lost - proceed with caution!
3+
4+
__metadata:
5+
version: 8
6+
cacheKey: 10c0
7+
8+
"config-not-found@workspace:.":
9+
version: 0.0.0-use.local
10+
resolution: "config-not-found@workspace:."
11+
languageName: unknown
12+
linkType: soft
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

packages/cli-v3/e2e/fixtures/trigger-dir-missing/package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "trigger-dir-missing",
3+
"private": true,
4+
"packageManager": "[email protected]+sha256.1aa43a5304405be7a7cb9cb5de7b97de9c4e8ddd3273e4dad00d6ae3eb39f0ef",
5+
"engines": {
6+
"pnpm": "8.15.5",
7+
"yarn": "4.2.2"
8+
}
9+
}

packages/cli-v3/e2e/fixtures/trigger-dir-missing/pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# https://github.com/pnpm/pnpm/issues/2412
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const config = {
2+
project: "bad-config",
3+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is generated by running "yarn install" inside your project.
2+
# Manual changes might be lost - proceed with caution!
3+
4+
__metadata:
5+
version: 8
6+
cacheKey: 10c0
7+
8+
"trigger-dir-missing@workspace:.":
9+
version: 0.0.0-use.local
10+
resolution: "trigger-dir-missing@workspace:."
11+
languageName: unknown
12+
linkType: soft
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

packages/cli-v3/e2e/fixtures/trigger-dir-not-found/package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "trigger-dir-not-found",
3+
"private": true,
4+
"packageManager": "[email protected]+sha256.1aa43a5304405be7a7cb9cb5de7b97de9c4e8ddd3273e4dad00d6ae3eb39f0ef",
5+
"engines": {
6+
"pnpm": "8.15.5",
7+
"yarn": "4.2.2"
8+
}
9+
}

packages/cli-v3/e2e/fixtures/trigger-dir-not-found/pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# https://github.com/pnpm/pnpm/issues/2412
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const config = {
2+
project: "bad-config",
3+
triggerDirectories: ["./unknown-folder"],
4+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is generated by running "yarn install" inside your project.
2+
# Manual changes might be lost - proceed with caution!
3+
4+
__metadata:
5+
version: 8
6+
cacheKey: 10c0
7+
8+
"trigger-dir-not-found@workspace:.":
9+
version: 0.0.0-use.local
10+
resolution: "trigger-dir-not-found@workspace:."
11+
languageName: unknown
12+
linkType: soft

packages/cli-v3/e2e/index.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type TestCase = {
1818
name: string;
1919
skipTypecheck?: boolean;
2020
wantConfigNotFoundError?: boolean;
21-
wantBadConfigError?: boolean;
21+
wantConfigInvalidError?: boolean;
2222
wantCompilationError?: boolean;
2323
wantWorkerError?: boolean;
2424
wantDependenciesError?: boolean;
@@ -109,7 +109,7 @@ if (testCases.length > 0) {
109109
name,
110110
skipTypecheck,
111111
wantConfigNotFoundError,
112-
wantBadConfigError,
112+
wantConfigInvalidError,
113113
wantCompilationError,
114114
wantWorkerError,
115115
wantDependenciesError,
@@ -157,7 +157,7 @@ if (testCases.length > 0) {
157157
(async () => {
158158
global.resolvedConfig = await readConfig(fixtureDir, { cwd: fixtureDir });
159159
})(),
160-
wantConfigNotFoundError || wantBadConfigError
160+
wantConfigNotFoundError || wantConfigInvalidError
161161
? "does not resolve config"
162162
: "resolves config"
163163
);
@@ -167,9 +167,9 @@ if (testCases.length > 0) {
167167
await configExpect.resolves.not.toThrowError();
168168
}
169169

170-
if (wantConfigNotFoundError || wantBadConfigError) {
171-
if (wantBadConfigError) {
172-
expect(global.resolvedConfig).toBe("error");
170+
if (wantConfigNotFoundError || wantConfigInvalidError) {
171+
if (wantConfigInvalidError) {
172+
expect(global.resolvedConfig!.status).toBe("error");
173173
}
174174
return;
175175
}

packages/cli-v3/e2e/testCases.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
[
22
{
3-
"name": "no-config",
3+
"name": "config-invalid",
4+
"wantConfigInvalidError": true
5+
},
6+
{
7+
"name": "config-not-found",
48
"wantConfigNotFoundError": true
59
},
610
{

packages/cli-v3/src/utilities/configFiles.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,11 @@ export async function readConfig(
227227
export async function resolveConfig(path: string, config: Config): Promise<ResolvedConfig> {
228228
if (!config.triggerDirectories) {
229229
config.triggerDirectories = await findTriggerDirectories(path);
230+
// TODO trigger-dir-missing: throw error if no trigger directory is found
230231
}
231232

232233
config.triggerDirectories = resolveTriggerDirectories(path, config.triggerDirectories);
234+
// TODO trigger-dir-not-found: throw error if trigger directories do not exist
233235

234236
logger.debug("Resolved trigger directories", { triggerDirectories: config.triggerDirectories });
235237

0 commit comments

Comments
 (0)