mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-11 04:22:13 +00:00
This PR update the tests suite to wait for Vercel CLI tarball and then use that tarball to run E2E tests. This is valuable because it will package all the packages in this monorepo to make the tests follow more closely what will happen in production once merged. Since the current "Find Changes" step takes about 2 minutes, we run that first (it happens concurrently with the tarball preparation). Then once we complete "Find Changes" we wait for the tarball but it will likely be ready by that point since it also takes about 2 minutes. After both of those steps, the E2E tests continue as usual but with the `VERCEL_CLI_VERSION` set to the tarball. - Related to #7967 - Closes #8245 - Closes #8227
64 lines
2.1 KiB
JavaScript
Vendored
64 lines
2.1 KiB
JavaScript
Vendored
const fs = require('fs');
|
|
const path = require('path');
|
|
const { intoChunks, NUMBER_OF_CHUNKS } = require('../../../utils/chunk-tests');
|
|
|
|
const {
|
|
testDeployment,
|
|
} = require('../../../test/lib/deployment/test-deployment.js');
|
|
|
|
jest.setTimeout(12 * 60 * 1000);
|
|
|
|
module.exports = function setupTests(groupIndex) {
|
|
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
|
const testsThatFailToBuild = new Map([
|
|
[
|
|
'04-wrong-dist-dir',
|
|
'No Output Directory named "out" found after the Build completed. You can configure the Output Directory in your Project Settings.',
|
|
],
|
|
['05-empty-dist-dir', 'The Output Directory "dist" is empty.'],
|
|
[
|
|
'06-missing-script',
|
|
'Missing required "vercel-build" script in "package.json"',
|
|
],
|
|
['07-nonzero-sh', 'Command "./build.sh" exited with 1'],
|
|
[
|
|
'22-docusaurus-2-build-fail',
|
|
'No Output Directory named "build" found after the Build completed. You can configure the Output Directory in your Project Settings.',
|
|
],
|
|
[
|
|
'36-hugo-version-not-found',
|
|
'Version 0.0.0 of Hugo does not exist. Please specify a different one.',
|
|
],
|
|
]);
|
|
let fixtures = fs.readdirSync(fixturesPath);
|
|
|
|
if (typeof groupIndex !== 'undefined') {
|
|
fixtures = intoChunks(NUMBER_OF_CHUNKS, fixtures)[groupIndex - 1];
|
|
|
|
console.log('testing group', groupIndex, fixtures);
|
|
}
|
|
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
for (const fixture of fixtures) {
|
|
const errMsg = testsThatFailToBuild.get(fixture);
|
|
if (errMsg) {
|
|
// eslint-disable-next-line no-loop-func
|
|
it(`should fail to build ${fixture}`, async () => {
|
|
try {
|
|
await testDeployment(path.join(fixturesPath, fixture));
|
|
} catch (err) {
|
|
expect(err).toBeTruthy();
|
|
expect(err.deployment).toBeTruthy();
|
|
expect(err.deployment.errorMessage).toBe(errMsg);
|
|
}
|
|
});
|
|
continue; //eslint-disable-line
|
|
}
|
|
it(`should build ${fixture}`, async () => {
|
|
await expect(
|
|
testDeployment(path.join(fixturesPath, fixture))
|
|
).resolves.toBeDefined();
|
|
});
|
|
}
|
|
};
|