Skip to content

Commit b598060

Browse files
committed
test: add edge-runtime environment tests
- https://vitest.dev/guide/environment - https://edge-runtime.vercel.app Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent d1d72a8 commit b598060

20 files changed

Lines changed: 1142 additions & 33 deletions

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
"@arethetypeswrong/cli": "0.18.2",
173173
"@commitlint/cli": "20.4.1",
174174
"@commitlint/types": "20.4.0",
175+
"@edge-runtime/vm": "5.0.0",
175176
"@faker-js/faker": "10.3.0",
176177
"@flex-development/commitlint-config": "1.0.1",
177178
"@flex-development/eslint-config": "1.1.1",
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`e2e:mlly > should expose public api 1`] = `
4+
[
5+
"canParseUrl",
6+
"cwd",
7+
"defaultConditions",
8+
"defaultExtensions",
9+
"defaultMainFields",
10+
"extensionFormatMap",
11+
"formats",
12+
"getSource",
13+
"isAbsoluteSpecifier",
14+
"isArrayIndex",
15+
"isBareSpecifier",
16+
"isDirectory",
17+
"isFile",
18+
"isImportsSubpath",
19+
"isModuleId",
20+
"isRelativeSpecifier",
21+
"lookupPackageScope",
22+
"patternKeyCompare",
23+
"patternMatch",
24+
"readPackageJson",
25+
"resolveAlias",
26+
"resolveModule",
27+
"resolver",
28+
"root",
29+
"toRelativeSpecifier",
30+
"toUrl",
31+
"legacyMainResolve",
32+
"moduleResolve",
33+
"packageExportsResolve",
34+
"packageImportsExportsResolve",
35+
"packageImportsResolve",
36+
"packageResolve",
37+
"packageSelfResolve",
38+
"packageTargetResolve",
39+
]
40+
`;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`unit:internal/invalidPackageTarget > should return new \`ERR_INVALID_PACKAGE_TARGET\` (0) 1`] = `Invalid "imports" target "./__fixtures__/node_modules/*" defined for '#nm/*' in the package config \${process.cwd()}/package.json imported from \${process.cwd()}/src/internal/__tests__/invalid-package-target.spec.mts`;
4+
5+
exports[`unit:internal/invalidPackageTarget > should return new \`ERR_INVALID_PACKAGE_TARGET\` (1) 1`] = `Invalid "exports" main target "[null]" defined in the package config \${process.cwd()}/__fixtures__/node_modules/invalid-target-array/package.json; targets must start with "./"`;
6+
7+
exports[`unit:internal/invalidPackageTarget > should return new \`ERR_INVALID_PACKAGE_TARGET\` (2) 1`] = `Invalid "exports" main target "13n" defined in the package config \${process.cwd()}/__fixtures__/node_modules/invalid-target-bigint/package.json; targets must start with "./"`;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`unit:internal/invalidSubpath > should return new \`ERR_INVALID_MODULE_SPECIFIER\` (0) 1`] = `Invalid module './node_modules/esbuild/lib/main.js' request is not a valid match in pattern "./*" for the "exports" resolution of \${process.cwd()}/__fixtures__/node_modules/build-exports/package.json`;
4+
5+
exports[`unit:internal/invalidSubpath > should return new \`ERR_INVALID_MODULE_SPECIFIER\` (1) 1`] = `Invalid module '#fixtures/node_modules/subpath-imports/package.json' request is not a valid match in pattern "#fixtures/*" for the "imports" resolution of \${process.cwd()}/package.json`;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`unit:lib/cwd > should return URL of current working directory 1`] = `file://\${process.cwd()}/`;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`unit:lib/defaultConditions > should contain default conditions 1`] = `
4+
Set {
5+
"node",
6+
"import",
7+
}
8+
`;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`unit:lib/defaultExtensions > should contain default extensions 1`] = `
4+
Set {
5+
".mjs",
6+
".mts",
7+
".cjs",
8+
".cts",
9+
".js",
10+
".ts",
11+
".jsx",
12+
".tsx",
13+
".css",
14+
".json",
15+
".node",
16+
".wasm",
17+
".d.mts",
18+
".d.cts",
19+
".d.ts",
20+
}
21+
`;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`unit:lib/extensionFormatMap > should map extensions to module formats 1`] = `
4+
Map {
5+
".cjs" => "commonjs",
6+
".cts" => "commonjs-typescript",
7+
".d.cts" => "commonjs-typescript",
8+
".d.mts" => "module-typescript",
9+
".d.ts" => "module-typescript",
10+
".js" => "module",
11+
".json" => "json",
12+
".jsx" => "module",
13+
".mjs" => "module",
14+
".mts" => "module-typescript",
15+
".node" => "commonjs",
16+
".ts" => "module-typescript",
17+
".tsx" => "module-typescript",
18+
".wasm" => "wasm",
19+
}
20+
`;
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`unit:lib/getSource > fs (default) > data: > should return source code for \`id\` (0) 1`] = `"Hello, World!"`;
4+
5+
exports[`unit:lib/getSource > fs (default) > data: > should return source code for \`id\` (1) 1`] = `"console.log("hello!");"`;
6+
7+
exports[`unit:lib/getSource > fs (default) > file: > should return source code for \`id\` (0) 1`] = `
8+
"{
9+
"$schema": "https://raw.githubusercontent.com/flex-development/grease/main/grease.schema.json",
10+
"tag": {
11+
"message": "release: {tag}",
12+
"sign": true
13+
},
14+
"tagprefix": ""
15+
}
16+
"
17+
`;
18+
19+
exports[`unit:lib/getSource > fs (default) > file: > should return source code for \`id\` (1) 1`] = `
20+
"/**
21+
* @file Configuration - Vite
22+
* @module config/vite
23+
* @see https://vite.dev/config
24+
*/
25+
26+
import type { UserConfig } from 'vite'
27+
import tsconfig from './tsconfig.json' with { type: 'json' }
28+
29+
/**
30+
* Vite configuration.
31+
*
32+
* @const {UserConfig} config
33+
*/
34+
const config: UserConfig = {
35+
resolve: {
36+
conditions: ['browser', ...tsconfig.compilerOptions.customConditions]
37+
}
38+
}
39+
40+
export default config
41+
"
42+
`;
43+
44+
exports[`unit:lib/getSource > fs (default) > http[s]: > should return source code for \`id\` (0) 1`] = `
45+
"
46+
/* esm.sh - @flex-development/mlly@1.0.0-alpha.20 */
47+
import "/#lib/index?target=es2022";
48+
export * from "/@flex-development/mlly@1.0.0-alpha.20/es2022/mlly.mjs";
49+
"
50+
`;
51+
52+
exports[`unit:lib/getSource > fs (only async) > data: > should return source code for \`id\` (0) 1`] = `"Hello, World!"`;
53+
54+
exports[`unit:lib/getSource > fs (only async) > data: > should return source code for \`id\` (1) 1`] = `"console.log("hello!");"`;
55+
56+
exports[`unit:lib/getSource > fs (only async) > file: > should return source code for \`id\` (0) 1`] = `
57+
"{
58+
"$schema": "https://raw.githubusercontent.com/flex-development/grease/main/grease.schema.json",
59+
"tag": {
60+
"message": "release: {tag}",
61+
"sign": true
62+
},
63+
"tagprefix": ""
64+
}
65+
"
66+
`;
67+
68+
exports[`unit:lib/getSource > fs (only async) > file: > should return source code for \`id\` (1) 1`] = `
69+
"/**
70+
* @file Configuration - Vite
71+
* @module config/vite
72+
* @see https://vite.dev/config
73+
*/
74+
75+
import type { UserConfig } from 'vite'
76+
import tsconfig from './tsconfig.json' with { type: 'json' }
77+
78+
/**
79+
* Vite configuration.
80+
*
81+
* @const {UserConfig} config
82+
*/
83+
const config: UserConfig = {
84+
resolve: {
85+
conditions: ['browser', ...tsconfig.compilerOptions.customConditions]
86+
}
87+
}
88+
89+
export default config
90+
"
91+
`;
92+
93+
exports[`unit:lib/getSource > fs (only async) > http[s]: > should return source code for \`id\` (0) 1`] = `
94+
"
95+
/* esm.sh - @flex-development/mlly@1.0.0-alpha.20 */
96+
import "/#lib/index?target=es2022";
97+
export * from "/@flex-development/mlly@1.0.0-alpha.20/es2022/mlly.mjs";
98+
"
99+
`;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`unit:lib/lookupPackageScope > fs (default) > should return URL of package directory (0) 1`] = `file://\${process.cwd()}/`;
4+
5+
exports[`unit:lib/lookupPackageScope > fs (default) > should return URL of package directory (1) 1`] = `file://\${process.cwd()}/`;
6+
7+
exports[`unit:lib/lookupPackageScope > fs (default) > should return URL of package directory (2) 1`] = `file://\${process.cwd()}/node_modules/@commitlint/cli/`;
8+
9+
exports[`unit:lib/lookupPackageScope > fs (default) > should return URL of package directory (3) 1`] = `file://\${process.cwd()}/node_modules/@flex-development/remark-preset/node_modules/micromark/`;
10+
11+
exports[`unit:lib/lookupPackageScope > fs (default) > should return URL of package directory (4) 1`] = `file://\${process.cwd()}/node_modules/vitest/`;
12+
13+
exports[`unit:lib/lookupPackageScope > fs (only async) > should return URL of package directory (0) 1`] = `file://\${process.cwd()}/`;
14+
15+
exports[`unit:lib/lookupPackageScope > fs (only async) > should return URL of package directory (1) 1`] = `file://\${process.cwd()}/`;
16+
17+
exports[`unit:lib/lookupPackageScope > fs (only async) > should return URL of package directory (2) 1`] = `file://\${process.cwd()}/node_modules/@commitlint/cli/`;
18+
19+
exports[`unit:lib/lookupPackageScope > fs (only async) > should return URL of package directory (3) 1`] = `file://\${process.cwd()}/node_modules/@flex-development/remark-preset/node_modules/micromark/`;
20+
21+
exports[`unit:lib/lookupPackageScope > fs (only async) > should return URL of package directory (4) 1`] = `file://\${process.cwd()}/node_modules/vitest/`;

0 commit comments

Comments
 (0)