Skip to content

Commit 4c6c6f6

Browse files
authored
test(e2e): Validate test app setup (#5849)
1 parent 2cda2bb commit 4c6c6f6

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

packages/e2e-tests/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
"lint": "run-s lint:prettier lint:eslint",
1414
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
1515
"lint:prettier": "prettier --config ../../.prettierrc.json --check .",
16-
"test:e2e": "run-s test:validate-configuration test:run",
16+
"test:e2e": "run-s test:validate-configuration test:test-app-setups test:run",
1717
"test:run": "ts-node run.ts",
18-
"test:validate-configuration": "ts-node validate-verdaccio-configuration.ts"
18+
"test:validate-configuration": "ts-node validate-verdaccio-configuration.ts",
19+
"test:test-app-setups": "ts-node validate-test-app-setups.ts"
1920
},
2021
"devDependencies": {
2122
"@types/glob": "8.0.0",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* eslint-disable no-console */
2+
import * as fs from 'fs';
3+
import * as glob from 'glob';
4+
import * as path from 'path';
5+
6+
const testRecipePaths = glob.sync('test-applications/*/test-recipe.json', {
7+
cwd: __dirname,
8+
absolute: true,
9+
});
10+
11+
testRecipePaths.forEach(testRecipePath => {
12+
const testAppPath = path.dirname(testRecipePath);
13+
const npmrcPath = path.resolve(testAppPath, '.npmrc');
14+
15+
if (!fs.existsSync(npmrcPath)) {
16+
console.log(
17+
`No .npmrc found in test application "${testAppPath}". Please add a .npmrc to this test application that uses the fake test registry. (More info in packages/e2e-tests/README.md)`,
18+
);
19+
process.exit(1);
20+
}
21+
22+
const npmrcContents = fs.readFileSync(npmrcPath, 'utf-8');
23+
if (!npmrcContents.includes('http://localhost:4873')) {
24+
console.log(
25+
`.npmrc in test application "${testAppPath} doesn't contain a reference to the fake test registry at "http://localhost:4873". Please add a .npmrc to this test application that uses the fake test registry. (More info in packages/e2e-tests/README.md)`,
26+
);
27+
process.exit(1);
28+
}
29+
30+
const gitignorePath = path.resolve(testAppPath, '.gitignore');
31+
32+
if (!fs.existsSync(gitignorePath)) {
33+
console.log(
34+
`No .gitignore found in test application "${testAppPath}". Please add a .gitignore to this test application that ignores any kind of lockfiles. (More info in packages/e2e-tests/README.md)`,
35+
);
36+
process.exit(1);
37+
}
38+
39+
const gitignoreContents = fs.readFileSync(gitignorePath, 'utf-8');
40+
if (!gitignoreContents.includes('lock')) {
41+
console.log(
42+
`.gitignore in test application "${testAppPath} doesn't contain an entry for a lockfile. Please add a .gitignore to this test application that ignores any kind of lockfiles. (More info in packages/e2e-tests/README.md)`,
43+
);
44+
process.exit(1);
45+
}
46+
});

0 commit comments

Comments
 (0)