@@ -497,15 +497,10 @@ describe(`read-only and offline environment`, () => {
497
497
exitCode : 0 ,
498
498
} ) ;
499
499
500
- // Let corepack discover the latest yarn version.
501
- // BUG: This should not be necessary with a fully specified version in package.json plus populated corepack cache.
502
- // Engine.executePackageManagerRequest needs to defer the fallback work. This requires a big refactoring.
503
- await expect ( runCli ( cwd , [ `yarn` , `--version` ] ) ) . resolves . toMatchObject ( {
504
- exitCode : 0 ,
505
- } ) ;
506
-
507
500
// Make COREPACK_HOME ro
508
501
const home = npath . toPortablePath ( folderUtils . getCorepackHomeFolder ( ) ) ;
502
+ // Make a lastKnownGood.json file with not JSON-parsable content:
503
+ await xfs . writeFilePromise ( ppath . join ( home , `lastKnownGood.json` ) , `{` ) ;
509
504
await xfs . chmodPromise ( ppath . join ( home , `lastKnownGood.json` ) , 0o444 ) ;
510
505
await xfs . chmodPromise ( home , 0o555 ) ;
511
506
@@ -967,54 +962,63 @@ for (const authType of [`COREPACK_NPM_REGISTRY`, `COREPACK_NPM_TOKEN`, `COREPACK
967
962
describe ( `handle integrity checks` , ( ) => {
968
963
beforeEach ( ( ) => {
969
964
process . env . AUTH_TYPE = `COREPACK_NPM_TOKEN` ; // See `_registryServer.mjs`
970
- process . env . COREPACK_DEFAULT_TO_LATEST = `1` ;
971
965
} ) ;
972
966
973
- it ( `should return no error when signature matches` , async ( ) => {
974
- process . env . TEST_INTEGRITY = `valid` ; // See `_registryServer.mjs`
975
-
976
- await xfs . mktempPromise ( async cwd => {
977
- await Promise . all ( [
978
- expect ( runCli ( cwd , [ `pnpm` , `--version` ] , true ) ) . resolves . toMatchObject ( {
979
- exitCode : 0 ,
980
- stdout : `pnpm: Hello from custom registry\n` ,
981
- stderr : `` ,
982
- } ) ,
983
- expect ( runCli ( cwd , [ `[email protected] ` , `--version` ] , true ) ) . resolves . toMatchObject ( {
984
- exitCode : 0 ,
985
- stdout : `yarn: Hello from custom registry\n` ,
986
- stderr : `` ,
987
- } ) ,
988
- expect ( runCli ( cwd , [ `[email protected] ` , `--version` ] , true ) ) . resolves . toMatchObject ( {
989
- exitCode : 0 ,
990
- stdout : `yarn: Hello from custom registry\n` ,
991
- stderr : `` ,
992
- } ) ,
993
- ] ) ;
967
+ describe ( `when signature matches` , ( ) => {
968
+ beforeEach ( ( ) => {
969
+ process . env . TEST_INTEGRITY = `valid` ; // See `_registryServer.mjs`
970
+ } ) ;
994
971
972
+ it ( `should return no error when calling 'corepack use'` , async ( ) => {
973
+ await xfs . mktempPromise ( async cwd => {
995
974
// Skip rest of the test on Windows & Node.js 18.x as it inevitably times out otherwise.
996
- if ( process . version . startsWith ( `v18.` ) && os . platform ( ) === `win32` ) return ;
975
+ if ( process . version . startsWith ( `v18.` ) && os . platform ( ) === `win32` ) return ;
976
+
977
+ // Removing home directory to force the "re-download"
978
+ await xfs . rmPromise ( process . env . COREPACK_HOME as any , { recursive : true } ) ;
979
+
980
+ await Promise . all ( [
981
+ expect ( runCli ( cwd , [ `use` , `pnpm` ] , true ) ) . resolves . toMatchObject ( {
982
+ exitCode : 0 ,
983
+ stdout :
`Installing [email protected] in the project...\n\npnpm: Hello from custom registry\n` ,
984
+ stderr : `` ,
985
+ } ) ,
986
+ expect ( runCli ( cwd , [ `use` , `[email protected] ` ] , true ) ) . resolves . toMatchObject ( {
987
+ exitCode : 0 ,
988
+ stdout :
`Installing [email protected] in the project...\n\nyarn: Hello from custom registry\n` ,
989
+ stderr : `` ,
990
+ } ) ,
991
+ expect ( runCli ( cwd , [ `use` , `yarn@latest` ] , true ) ) . resolves . toMatchObject ( {
992
+ exitCode : 0 ,
993
+ stdout :
`Installing [email protected] in the project...\n\nyarn: Hello from custom registry\n` ,
994
+ stderr : `` ,
995
+ } ) ,
996
+ ] ) ;
997
+ } ) ;
998
+ } ) ;
997
999
998
- // Removing home directory to force the "re-download"
999
- await xfs . rmPromise ( process . env . COREPACK_HOME as any , { recursive : true } ) ;
1000
1000
1001
- await Promise . all ( [
1002
- expect ( runCli ( cwd , [ `use` , `pnpm` ] , true ) ) . resolves . toMatchObject ( {
1003
- exitCode : 0 ,
1004
- stdout :
`Installing [email protected] in the project...\n\npnpm: Hello from custom registry\n` ,
1005
- stderr : `` ,
1006
- } ) ,
1007
- expect ( runCli ( cwd , [ `use` , `[email protected] ` ] , true ) ) . resolves . toMatchObject ( {
1008
- exitCode : 0 ,
1009
- stdout :
`Installing [email protected] in the project...\n\nyarn: Hello from custom registry\n` ,
1010
- stderr : `` ,
1011
- } ) ,
1012
- expect ( runCli ( cwd , [ `use` , `yarn@latest` ] , true ) ) . resolves . toMatchObject ( {
1013
- exitCode : 0 ,
1014
- stdout :
`Installing [email protected] in the project...\n\nyarn: Hello from custom registry\n` ,
1015
- stderr : `` ,
1016
- } ) ,
1017
- ] ) ;
1001
+ it ( `should return no error when fetching latest version` , async ( ) => {
1002
+ process . env . COREPACK_DEFAULT_TO_LATEST = `1` ;
1003
+ await xfs . mktempPromise ( async cwd => {
1004
+ await Promise . all ( [
1005
+ expect ( runCli ( cwd , [ `pnpm` , `--version` ] , true ) ) . resolves . toMatchObject ( {
1006
+ exitCode : 0 ,
1007
+ stdout : `pnpm: Hello from custom registry\n` ,
1008
+ stderr : `` ,
1009
+ } ) ,
1010
+ expect ( runCli ( cwd , [ `[email protected] ` , `--version` ] , true ) ) . resolves . toMatchObject ( {
1011
+ exitCode : 0 ,
1012
+ stdout : `yarn: Hello from custom registry\n` ,
1013
+ stderr : `` ,
1014
+ } ) ,
1015
+ expect ( runCli ( cwd , [ `[email protected] ` , `--version` ] , true ) ) . resolves . toMatchObject ( {
1016
+ exitCode : 0 ,
1017
+ stdout : `yarn: Hello from custom registry\n` ,
1018
+ stderr : `` ,
1019
+ } ) ,
1020
+ ] ) ;
1021
+ } ) ;
1018
1022
} ) ;
1019
1023
} ) ;
1020
1024
it ( `should return an error when signature does not match with a tag` , async ( ) => {
0 commit comments