mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 21:07:46 +00:00
[all] Fix test fixture pkg names and increase retry (#3935)
Fixes test warnings from `jest-hast-map`:
```
[now-static-build] Running yarn test-integration-once
$ jest --env node --verbose --runInBand test/integration.test.js
jest-haste-map: Haste module naming collision: 12-create-react-app
The following files share their name; please adjust your hasteImpl:
* <rootDir>/test/fixtures/12-create-react-app/package.json
* <rootDir>/test/fixtures/26-ejected-cra/package.json
jest-haste-map: Haste module naming collision: gatsby-starter-default
The following files share their name; please adjust your hasteImpl:
* <rootDir>/test/fixtures/10-gatsby/package.json
* <rootDir>/test/fixtures/10-gatsby-without-build-script/package.json
jest-haste-map: Haste module naming collision: gohugo-default-theme
The following files share their name; please adjust your hasteImpl:
* <rootDir>/test/fixtures/31-hugo/themes/ananke/package.json
* <rootDir>/test/fixtures/46-hugo-with-framework/themes/ananke/package.json
jest-haste-map: Haste module naming collision: gohugo-default-styles
The following files share their name; please adjust your hasteImpl:
* <rootDir>/test/fixtures/31-hugo/themes/ananke/src/package.json
* <rootDir>/test/fixtures/46-hugo-with-framework/themes/ananke/src/package.json
jest-haste-map: Haste module naming collision: 47-nuxt-with-custom-output
The following files share their name; please adjust your hasteImpl:
* <rootDir>/test/fixtures/47-nuxt-with-custom-output/package.json
* <rootDir>/test/fixtures/48-nuxt-without-framework/package.json
```
Also increased test retry to 5.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "gatsby-starter-default",
|
"name": "gatsby",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"gatsby": "^2.18.14",
|
"gatsby": "^2.18.14",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "gridsomee",
|
"name": "gridsome",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gridsome build",
|
"build": "gridsome build",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
resolve: `gatsby-plugin-manifest`,
|
resolve: `gatsby-plugin-manifest`,
|
||||||
options: {
|
options: {
|
||||||
name: `gatsby-starter-default`,
|
name: `05-zero-config-gatsby`,
|
||||||
short_name: `starter`,
|
short_name: `starter`,
|
||||||
start_url: `/`,
|
start_url: `/`,
|
||||||
background_color: `#663399`,
|
background_color: `#663399`,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "gatsby-starter-default",
|
"name": "05-zero-config-gatsby",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "A simple starter to get up and developing quickly with Gatsby",
|
"description": "A simple starter to get up and developing quickly with Gatsby",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
resolve: `gatsby-plugin-manifest`,
|
resolve: `gatsby-plugin-manifest`,
|
||||||
options: {
|
options: {
|
||||||
name: `gatsby-starter-default`,
|
name: `05-gatsby`,
|
||||||
short_name: `starter`,
|
short_name: `starter`,
|
||||||
start_url: `/`,
|
start_url: `/`,
|
||||||
background_color: `#663399`,
|
background_color: `#663399`,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "gatsby-starter-default",
|
"name": "05-gatsby",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "A simple starter to get up and developing quickly with Gatsby",
|
"description": "A simple starter to get up and developing quickly with Gatsby",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "gohugo-default-theme",
|
"name": "08-gohugo-default-theme",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Base Theme to start Hugo Sites",
|
"description": "Base Theme to start Hugo Sites",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|||||||
20
packages/now-cli/test/integration.js
vendored
20
packages/now-cli/test/integration.js
vendored
@@ -20,6 +20,7 @@ import logo from '../src/util/output/logo';
|
|||||||
import sleep from '../src/util/sleep';
|
import sleep from '../src/util/sleep';
|
||||||
import pkg from '../package';
|
import pkg from '../package';
|
||||||
import prepareFixtures from './helpers/prepare';
|
import prepareFixtures from './helpers/prepare';
|
||||||
|
import { fetchTokenWithRetry } from '../../../test/lib/deployment/now-deploy';
|
||||||
|
|
||||||
// log command when running `execa`
|
// log command when running `execa`
|
||||||
function execa(file, args, options) {
|
function execa(file, args, options) {
|
||||||
@@ -70,25 +71,6 @@ const waitForDeployment = async href => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function fetchTokenWithRetry(url, retries = 3) {
|
|
||||||
return retry(
|
|
||||||
async () => {
|
|
||||||
const res = await fetch(url);
|
|
||||||
|
|
||||||
if (!res.ok) {
|
|
||||||
throw new Error(
|
|
||||||
`Failed to fetch ${url}, received status ${res.status}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await res.json();
|
|
||||||
|
|
||||||
return data.token;
|
|
||||||
},
|
|
||||||
{ retries, factor: 1 }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetchTokenInformation(token, retries = 3) {
|
function fetchTokenInformation(token, retries = 3) {
|
||||||
const url = `https://api.zeit.co/www/user`;
|
const url = `https://api.zeit.co/www/user`;
|
||||||
const headers = { Authorization: `Bearer ${token}` };
|
const headers = { Authorization: `Bearer ${token}` };
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
resolve: `gatsby-plugin-manifest`,
|
resolve: `gatsby-plugin-manifest`,
|
||||||
options: {
|
options: {
|
||||||
name: `gatsby-starter-default`,
|
name: `10-gatsby-without-build-script`,
|
||||||
short_name: `starter`,
|
short_name: `starter`,
|
||||||
start_url: `/`,
|
start_url: `/`,
|
||||||
background_color: `#663399`,
|
background_color: `#663399`,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "gatsby-starter-default",
|
"name": "10-gatsby-without-build-script",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "A simple starter to get up and developing quickly with Gatsby",
|
"description": "A simple starter to get up and developing quickly with Gatsby",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
resolve: `gatsby-plugin-manifest`,
|
resolve: `gatsby-plugin-manifest`,
|
||||||
options: {
|
options: {
|
||||||
name: `gatsby-starter-default`,
|
name: `10-gatsby`,
|
||||||
short_name: `starter`,
|
short_name: `starter`,
|
||||||
start_url: `/`,
|
start_url: `/`,
|
||||||
background_color: `#663399`,
|
background_color: `#663399`,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "gatsby-starter-default",
|
"name": "10-gatsby",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "A simple starter to get up and developing quickly with Gatsby",
|
"description": "A simple starter to get up and developing quickly with Gatsby",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "12-create-react-app",
|
"name": "26-ejected-cra",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "gohugo-default-theme",
|
"name": "31-gohugo-default-theme",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Base Theme to start Hugo Sites",
|
"description": "Base Theme to start Hugo Sites",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "gohugo-default-theme",
|
"name": "46-gohugo-default-theme",
|
||||||
"version": "2.5.5",
|
"version": "2.5.5",
|
||||||
"description": "Base Theme to start Hugo Sites",
|
"description": "Base Theme to start Hugo Sites",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "47-nuxt-with-custom-output",
|
"name": "48-nuxt-without-framework",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "pages/index.js",
|
"main": "pages/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { createHash } = require('crypto');
|
const { createHash } = require('crypto');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const _fetch = require('node-fetch');
|
||||||
const fetch = require('./fetch-retry.js');
|
const fetch = require('./fetch-retry.js');
|
||||||
|
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
|
||||||
const str = 'aHR0cHM6Ly9hcGktdG9rZW4tZmFjdG9yeS56ZWl0LnNo';
|
const str = 'aHR0cHM6Ly9hcGktdG9rZW4tZmFjdG9yeS56ZWl0LnNo';
|
||||||
|
|
||||||
async function nowDeploy(bodies, randomness) {
|
async function nowDeploy(bodies, randomness) {
|
||||||
const files = Object.keys(bodies)
|
const files = Object.keys(bodies)
|
||||||
.filter((n) => n !== 'now.json')
|
.filter(n => n !== 'now.json')
|
||||||
.map((n) => ({
|
.map(n => ({
|
||||||
sha: digestOfFile(bodies[n]),
|
sha: digestOfFile(bodies[n]),
|
||||||
size: bodies[n].length,
|
size: bodies[n].length,
|
||||||
file: n,
|
file: n,
|
||||||
@@ -55,7 +57,8 @@ async function nowDeploy (bodies, randomness) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
const json = await deploymentPost(nowDeployPayload);
|
const json = await deploymentPost(nowDeployPayload);
|
||||||
if (json.error && json.error.code === 'missing_files') throw new Error('Missing files');
|
if (json.error && json.error.code === 'missing_files')
|
||||||
|
throw new Error('Missing files');
|
||||||
deploymentId = json.id;
|
deploymentId = json.id;
|
||||||
deploymentUrl = json.url;
|
deploymentUrl = json.url;
|
||||||
}
|
}
|
||||||
@@ -65,9 +68,10 @@ async function nowDeploy (bodies, randomness) {
|
|||||||
|
|
||||||
for (let i = 0; i < 750; i += 1) {
|
for (let i = 0; i < 750; i += 1) {
|
||||||
const { state } = await deploymentGet(deploymentId);
|
const { state } = await deploymentGet(deploymentId);
|
||||||
if (state === 'ERROR') throw new Error(`State of ${deploymentUrl} is ${state}`);
|
if (state === 'ERROR')
|
||||||
|
throw new Error(`State of ${deploymentUrl} is ${state}`);
|
||||||
if (state === 'READY') break;
|
if (state === 'READY') break;
|
||||||
await new Promise((r) => setTimeout(r, 1000));
|
await new Promise(r => setTimeout(r, 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
return { deploymentId, deploymentUrl };
|
return { deploymentId, deploymentUrl };
|
||||||
@@ -136,7 +140,7 @@ async function deploymentGet (deploymentId) {
|
|||||||
console.log('Fetch Error', { url, status, statusText, headers });
|
console.log('Fetch Error', { url, status, statusText, headers });
|
||||||
throw new Error(message);
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
return json
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
let token;
|
let token;
|
||||||
@@ -166,25 +170,30 @@ async function fetchWithAuth (url, opts = {}) {
|
|||||||
return await fetchApi(url, opts);
|
return await fetchApi(url, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchTokenWithRetry (url, retries = 3) {
|
async function fetchTokenWithRetry(url, retries = 5) {
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(url);
|
const res = await _fetch(url);
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`Unexpected status from token factory: ${res.status}`);
|
||||||
|
}
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
resolve(data.token);
|
if (!data) {
|
||||||
|
throw new Error(`Unexpected response from token factory: no body`);
|
||||||
|
}
|
||||||
|
if (!data.token) {
|
||||||
|
const text = JSON.stringify(data);
|
||||||
|
throw new Error(`Unexpected response from token factory: ${text}`);
|
||||||
|
}
|
||||||
|
return data.token;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`Failed to fetch token. Retries remaining: ${retries}`);
|
console.log(`Failed to fetch token. Retries remaining: ${retries}`);
|
||||||
if (retries === 0) {
|
if (retries === 0) {
|
||||||
reject(error);
|
console.log(error);
|
||||||
return;
|
throw error;
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
await sleep(500);
|
||||||
fetchTokenWithRetry(url, retries - 1)
|
return fetchTokenWithRetry(url, retries - 1);
|
||||||
.then(resolve)
|
|
||||||
.catch(reject);
|
|
||||||
}, 500);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchApi(url, opts = {}) {
|
async function fetchApi(url, opts = {}) {
|
||||||
@@ -212,4 +221,5 @@ module.exports = {
|
|||||||
fetchApi,
|
fetchApi,
|
||||||
fetchWithAuth,
|
fetchWithAuth,
|
||||||
nowDeploy,
|
nowDeploy,
|
||||||
|
fetchTokenWithRetry,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user