[tests] Add tests for examples (#9403)

These tests will run if one of the conditions is met:

- any change to `./examples`
- any changes to `./packages/frameworks`

The test ensures that examples can build and deploy without errors.

In a future PR, we could improve these tests to make requests to the
test deployment (like we do for probes).
This commit is contained in:
Steven
2023-02-09 09:58:37 -05:00
committed by GitHub
parent 8087b7804e
commit 26773daf05
60 changed files with 347 additions and 36 deletions

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,5 @@
import { deployExample } from '../test-utils';
it('should deploy', async () => {
await deployExample(__filename);
});

View File

@@ -0,0 +1,7 @@
import { basename, join } from 'path';
import { testDeployment } from '../../test/lib/deployment/test-deployment.js';
export async function deployExample(filename: string) {
const example = basename(filename).replace(/\.test\.ts$/, '');
await testDeployment(join(filename, '..', '..', '..', example));
}

View File

@@ -0,0 +1,26 @@
import { existsSync, lstatSync, readdirSync } from 'fs';
import { join } from 'path';
function getExamples() {
const dirname = join(__dirname, '..', '..');
const examples = readdirSync(dirname)
.map(example =>
({
exampleName: example,
examplePath: join(dirname, example),
testPath: join(dirname, '__tests__', 'integration', `${example}.test.ts`),
})
)
.filter(o =>
!o.exampleName.startsWith('.') &&
!o.exampleName.startsWith('_') &&
lstatSync(o.examplePath).isDirectory()
);
return examples;
}
describe('should have test for each example', () => {
it.each(getExamples())('should exist $exampleName', async ({testPath}) => {
expect(existsSync(testPath)).toBeTruthy();
});
});

View File

@@ -8,6 +8,9 @@
"lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
"test": "echo \"No tests yet\""
},
"engines": {
"node": "16.x"
},
"browserslist": [
"defaults"
],

View File

@@ -10,6 +10,9 @@
"test:functional": "dojo build --mode functional && dojo test --functional --config local",
"test:all": "dojo build --mode unit && dojo build --mode functional && dojo test --all --config local"
},
"engines": {
"node": "16.x"
},
"dependencies": {
"@dojo/framework": "^6.0.0",
"@dojo/themes": "^6.0.0",

View File

@@ -18,6 +18,9 @@
"url": "https://github.com/ionic-team/ionic-conference-app.git"
},
"private": true,
"engines": {
"node": "16.x"
},
"dependencies": {
"@angular/common": "^8.2.14",
"@angular/core": "^8.2.14",

View File

@@ -2,6 +2,9 @@
"name": "ionic-react",
"version": "0.0.1",
"private": true,
"engines": {
"node": "16.x"
},
"dependencies": {
"@ionic/react": "^4.11.0",
"@ionic/react-router": "^4.11.0",

7
examples/jest.config.js vendored Normal file
View File

@@ -0,0 +1,7 @@
/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['<rootDir>/__tests__/**/*.test.ts'],
testTimeout: 5 * 60 * 1000,
};

14
examples/package.json vendored Normal file
View File

@@ -0,0 +1,14 @@
{
"private": true,
"name": "examples",
"description": "Each subdirectory is an example boilerplate for a framework. This package.json only exists for testing purposes.",
"scripts": {
"test-unit": "pnpm test __tests__/unit/",
"test-integration-once": "pnpm test __tests__/integration/",
"test": "jest --env node --verbose --runInBand --bail"
},
"devDependencies": {
"@types/jest": "27.4.1",
"@vercel/frameworks": "1.3.0"
}
}

View File

@@ -7,6 +7,9 @@
"lint": "eslint src",
"test": "jest"
},
"engines": {
"node": "16.x"
},
"eslintConfig": {
"extends": "preact",
"ignorePatterns": [

View File

@@ -4,6 +4,9 @@
"dev": "saber",
"build": "saber build"
},
"engines": {
"node": "16.x"
},
"devDependencies": {
"saber": "latest",
"saber-theme-minima": "latest",

View File

@@ -1,7 +1,6 @@
{
"name": "TODO",
"description": "TODO",
"version": "0.0.1",
"name": "sapper",
"private": true,
"scripts": {
"start": "sapper dev",
"dev": "sapper dev --port $PORT",
@@ -10,6 +9,9 @@
"cy:open": "cypress open",
"test": "run-p --race dev cy:run"
},
"engines": {
"node": "16.x"
},
"dependencies": {
"compression": "^1.7.1",
"polka": "next",

View File

@@ -10,6 +10,9 @@
"scully": "scully"
},
"private": true,
"engines": {
"node": "16.x"
},
"dependencies": {
"@angular/animations": "~9.0.0-rc.7",
"@angular/common": "~9.0.0-rc.7",

View File

@@ -11,8 +11,8 @@
"format": "prettier --write ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "1.0.0-next.589",
"@sveltejs/adapter-auto": "1.0.0-next.65",
"@sveltejs/kit": "1.0.0-next.428",
"@types/cookie": "^0.5.1",
"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",

View File

@@ -2,8 +2,8 @@ lockfileVersion: 5.4
specifiers:
'@fontsource/fira-mono': ^4.5.0
'@sveltejs/adapter-auto': next
'@sveltejs/kit': next
'@sveltejs/adapter-auto': 1.0.0-next.65
'@sveltejs/kit': 1.0.0-next.428
'@types/cookie': ^0.5.1
cookie: ^0.4.1
prettier: ^2.6.2
@@ -32,8 +32,8 @@ devDependencies:
packages:
/@cloudflare/workers-types/3.14.1:
resolution: {integrity: sha512-B1/plF62pt+H2IJHvApK8fdOJAVsvojvacuac8x8s+JIyqbropMyqNqHTKLm3YD8ZFLGwYeFTudU+PQ7vGvBdA==}
/@cloudflare/workers-types/3.19.0:
resolution: {integrity: sha512-0FRcsz7Ea3jT+gc5gKPIYciykm1bbAaTpygdzpCwGt0RL+V83zWnYN30NWDW4rIHj/FHtz+MIuBKS61C8l7AzQ==}
dev: true
/@esbuild/linux-loong64/0.14.54:
@@ -69,19 +69,19 @@ packages:
'@jridgewell/sourcemap-codec': 1.4.14
dev: true
/@mapbox/node-pre-gyp/1.0.9:
resolution: {integrity: sha512-aDF3S3rK9Q2gey/WAttUlISduDItz5BU3306M9Eyv6/oS40aMprnopshtlKTykxRNIBEZuRMaZAnbrQ4QtKGyw==}
/@mapbox/node-pre-gyp/1.0.10:
resolution: {integrity: sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA==}
hasBin: true
dependencies:
detect-libc: 2.0.1
https-proxy-agent: 5.0.1
make-dir: 3.1.0
node-fetch: 2.6.7
node-fetch: 2.6.9
nopt: 5.0.0
npmlog: 5.0.1
rimraf: 3.0.2
semver: 7.3.7
tar: 6.1.11
semver: 7.3.8
tar: 6.1.13
transitivePeerDependencies:
- encoding
- supports-color
@@ -134,7 +134,7 @@ packages:
/@sveltejs/adapter-cloudflare/1.0.0-next.31:
resolution: {integrity: sha512-HhEFZP72GJ8AZGgFECKIiayDcLaAWi65pI0AnBfiNhCifYSlH/mPNWNVD4AWRDnXnH6XU+FLwhGDnIDwytTyYg==}
dependencies:
'@cloudflare/workers-types': 3.14.1
'@cloudflare/workers-types': 3.19.0
esbuild: 0.14.54
worktop: 0.8.0-next.14
dev: true
@@ -231,15 +231,15 @@ packages:
resolution: {integrity: sha512-hFCAETfI5cG8l5iAiLhMC2bReC5K7SIybzrxGorv+eGspIbIFsVw7Vg85GovXm/LxA08pIDrAlrhR6GN36XB/Q==}
hasBin: true
dependencies:
'@mapbox/node-pre-gyp': 1.0.9
acorn: 8.8.0
'@mapbox/node-pre-gyp': 1.0.10
acorn: 8.8.2
async-sema: 3.1.1
bindings: 1.5.0
estree-walker: 2.0.2
glob: 7.2.3
graceful-fs: 4.2.10
micromatch: 4.0.5
node-gyp-build: 4.5.0
node-gyp-build: 4.6.0
resolve-from: 5.0.0
rollup-pluginutils: 2.8.2
transitivePeerDependencies:
@@ -251,8 +251,8 @@ packages:
resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==}
dev: true
/acorn/8.8.0:
resolution: {integrity: sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==}
/acorn/8.8.2:
resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==}
engines: {node: '>=0.4.0'}
hasBin: true
dev: true
@@ -688,7 +688,7 @@ packages:
resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==}
engines: {node: '>= 8'}
dependencies:
minipass: 3.3.4
minipass: 3.3.6
dev: true
/fs.realpath/1.0.0:
@@ -893,18 +893,23 @@ packages:
resolution: {integrity: sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==}
dev: true
/minipass/3.3.4:
resolution: {integrity: sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw==}
/minipass/3.3.6:
resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==}
engines: {node: '>=8'}
dependencies:
yallist: 4.0.0
dev: true
/minipass/4.0.3:
resolution: {integrity: sha512-OW2r4sQ0sI+z5ckEt5c1Tri4xTgZwYDxpE54eqWlQloQRoWtXjqt9udJ5Z4dSv7wK+nfFI7FRXyCpBSft+gpFw==}
engines: {node: '>=8'}
dev: true
/minizlib/2.1.2:
resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==}
engines: {node: '>= 8'}
dependencies:
minipass: 3.3.4
minipass: 3.3.6
yallist: 4.0.0
dev: true
@@ -946,8 +951,8 @@ packages:
engines: {node: '>=10.5.0'}
dev: true
/node-fetch/2.6.7:
resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==}
/node-fetch/2.6.9:
resolution: {integrity: sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==}
engines: {node: 4.x || >=6.0.0}
peerDependencies:
encoding: ^0.1.0
@@ -967,8 +972,8 @@ packages:
formdata-polyfill: 4.0.10
dev: true
/node-gyp-build/4.5.0:
resolution: {integrity: sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==}
/node-gyp-build/4.6.0:
resolution: {integrity: sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==}
hasBin: true
dev: true
@@ -1163,8 +1168,8 @@ packages:
hasBin: true
dev: true
/semver/7.3.7:
resolution: {integrity: sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==}
/semver/7.3.8:
resolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==}
engines: {node: '>=10'}
hasBin: true
dependencies:
@@ -1338,13 +1343,13 @@ packages:
engines: {node: '>= 8'}
dev: true
/tar/6.1.11:
resolution: {integrity: sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==}
engines: {node: '>= 10'}
/tar/6.1.13:
resolution: {integrity: sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==}
engines: {node: '>=10'}
dependencies:
chownr: 2.0.0
fs-minipass: 2.1.0
minipass: 3.3.4
minipass: 4.0.3
minizlib: 2.1.2
mkdirp: 1.0.4
yallist: 4.0.0

7
examples/tsconfig.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"target": "esnext",
"module": "commonjs"
}
}

View File

@@ -5,6 +5,9 @@
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"engines": {
"node": "16.x"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^3.0.0"

10
pnpm-lock.yaml generated
View File

@@ -84,6 +84,14 @@ importers:
'@vercel/node': link:../packages/node
typescript: 4.3.4
examples:
specifiers:
'@types/jest': 27.4.1
'@vercel/frameworks': 1.3.0
devDependencies:
'@types/jest': 27.4.1
'@vercel/frameworks': link:../packages/frameworks
packages/build-utils:
specifiers:
'@iarna/toml': 2.2.3
@@ -6053,7 +6061,7 @@ packages:
/@types/jest-expect-message/1.0.3:
resolution: {integrity: sha512-sp70Lc8POkOcXHEcLERpX/7B/BtQiqIYz3AvC9ZMNKSaiDttr8hKvz9DljIn7N6WJi3ioVoTtB1utDAX46oPlg==}
dependencies:
'@types/jest': 27.4.1
'@types/jest': 29.2.1
dev: true
/@types/jest/27.4.1:

View File

@@ -1,3 +1,4 @@
packages:
- 'packages/*'
- 'api'
- 'examples'