Update Your Local Registry Setup to use Nx Release

Nx will create a tools/start-local-registry.ts script for starting a local registry and publishing packages to it in preparation for running end to end tests. If you have an existing tools/start-local-registry.ts script from a previous version of Nx, you should update it to use Nx Release to publish packages to the local registry. This will ensure that newly generated libraries are published appropriately when running end to end tests.

The Previous Version

The previous version of the tools/start-local-registry.ts script used publish targets on each project to publish the packages to the local registry. This is no longer necessary with Nx Release. You can identify the previous version by the nx run-many command that publishes the packages:

1/** 2 * This script starts a local registry for e2e testing purposes. 3 * It is meant to be called in jest's globalSetup. 4 */ 5import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry'; 6import { execFileSync } from 'child_process'; 7 8export default async () => { 9 // local registry target to run 10 const localRegistryTarget = '@demo-plugin-1800/source:local-registry'; 11 // storage folder for the local registry 12 const storage = './tmp/local-registry/storage'; 13 14 global.stopLocalRegistry = await startLocalRegistry({ 15 localRegistryTarget, 16 storage, 17 verbose: false, 18 }); 19 const nx = require.resolve('nx'); 20 execFileSync( 21 nx, 22 ['run-many', '--targets', 'publish', '--ver', '0.0.0-e2e', '--tag', 'e2e'], 23 { env: process.env, stdio: 'inherit' } 24 ); 25}; 26

If your script looks like this, you should update it.

The Updated Version

The updated version of the tools/start-local-registry.ts script uses Nx Release to publish the packages to the local registry. This is done by running releaseVersion and releasePublish functions from nx/release. Your updated script should look like this:

1/** 2 * This script starts a local registry for e2e testing purposes. 3 * It is meant to be called in jest's globalSetup. 4 */ 5import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry'; 6import { execFileSync } from 'child_process'; 7import { releasePublish, releaseVersion } from 'nx/release'; 8 9export default async () => { 10 // local registry target to run 11 const localRegistryTarget = '@demo-plugin-1800/source:local-registry'; 12 // storage folder for the local registry 13 const storage = './tmp/local-registry/storage'; 14 15 global.stopLocalRegistry = await startLocalRegistry({ 16 localRegistryTarget, 17 storage, 18 verbose: false, 19 }); 20 21 await releaseVersion({ 22 specifier: '0.0.0-e2e', 23 stageChanges: false, 24 gitCommit: false, 25 gitTag: false, 26 firstRelease: true, 27 generatorOptionsOverrides: { 28 skipLockFileUpdate: true, 29 }, 30 }); 31 await releasePublish({ 32 tag: 'e2e', 33 firstRelease: true, 34 }); 35}; 36