-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement verdaccio local npm registry for vitest-pool-workers tests (#…
…7902) * chore: configure eslint to ignore CommonJS config files (.cjs) as well as normal files (.js) * chore: suppress logs of cached builds and tests * chore: ensure wrangler can be published from Windows * chore: reduce noise on Windows tests using `run-in-tmp` * chore: ensure that NODE_EXTRA_CA_CERTS gets passed through turbo to jobs This was causing the C3 e2e tests to fail locally for people running behind WARP, since framework generators like Remix and Solid were trying to make Internet requests to get template files and crashing with self-signed certificates errors. * test: add new mock-npm-registry helper package * test: use new mock-npm-registry helper in vitest-pool-workers tests * test: use new mock-npm-registry helper in create-cloudflare e2e tests
- Loading branch information
1 parent
2636825
commit 4a20621
Showing
21 changed files
with
2,050 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ | |
"unenv", | ||
"unrevoke", | ||
"Untriaged", | ||
"userconfig", | ||
"versionless", | ||
"wasmvalue", | ||
"weakmap", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { startMockNpmRegistry } from "@cloudflare/mock-npm-registry"; | ||
|
||
export default async () => startMockNpmRegistry("create-cloudflare"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ["@cloudflare/eslint-config-worker"], | ||
ignorePatterns: ["/dist"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# mock-npm-registry | ||
|
||
This internal package can be used in tests by othe packages to set up a mock local npm registry, publish locally built copies of the packages and their dependencies, then install those packages into test fixtures. | ||
|
||
## Usage | ||
|
||
A good example is the vitest-pool-workers e2e tests. See packages/vitest-pool-workers/test/global-setup.ts | ||
|
||
```ts | ||
export default async function ({ provide }: GlobalSetupContext) { | ||
const stop = await startMockNpmRegistry("@cloudflare/vitest-pool-workers"); | ||
|
||
// Create temporary directory | ||
const projectPath = await createTestProject(); | ||
execSync("pnpm install", { cwd: projectPath, stdio: "ignore" }); | ||
|
||
provide("tmpPoolInstallationPath", projectPath); | ||
``` | ||
Here you can see that in Vitest global setup file, we are calling `startMockNpmRegistry()`. | ||
We pass in the `@cloudflare/vitest-pool-workers` package name, which will ensure that this package | ||
(and all its local dependencies, such as Wrangler, Miniflare, etc) is built and published to the mock registry. | ||
We then create a temporary test project that has a dependency on `@cloudflare/vitest-pool-workers` | ||
and then run `pnpm install`, which will install the locally published packages. | ||
The path to this temporary test project is provided to tests. | ||
## Debugging | ||
If you are having problems with the mock npm registry, you can get additional debug logging by setting the `NODE_DEBUG` environment variable. | ||
```env | ||
NODE_DEBUG=mock-npm-registry | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "@cloudflare/mock-npm-registry", | ||
"version": "0.0.0", | ||
"private": true, | ||
"type": "module", | ||
"exports": { | ||
".": "./dist/index.js" | ||
}, | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc", | ||
"check:lint": "eslint . --max-warnings=0", | ||
"check:types": "tsc" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "catalog:default", | ||
"@verdaccio/types": "^10.8.0", | ||
"get-port": "^7.0.0", | ||
"ts-dedent": "^2.2.0", | ||
"typescript": "catalog:default", | ||
"verdaccio": "^6.0.5" | ||
}, | ||
"volta": { | ||
"extends": "../../package.json" | ||
} | ||
} |
Oops, something went wrong.