-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests for resolutions feature (#4180)
* add tests with offline mirror * add fixtures
- Loading branch information
Showing
8 changed files
with
62 additions
and
2 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 |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
import {getPackageVersion, isPackagePresent, runInstall} from '../_helpers.js'; | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 150000; | ||
|
||
test.concurrent('install with simple exact resolutions should override all versions', (): Promise<void> => { | ||
return runInstall({}, {source: 'resolutions', cwd: 'simple-exact'}, async config => { | ||
expect(await getPackageVersion(config, 'a')).toEqual('1.0.0'); | ||
|
@@ -24,3 +26,28 @@ test.concurrent('install with subtree exact resolutions should override subtree | |
expect(await getPackageVersion(config, 'c/left-pad')).toEqual('1.1.2'); | ||
}); | ||
}); | ||
|
||
test.concurrent('install with exotic resolutions should override versions', (): Promise<void> => { | ||
return runInstall({}, {source: 'resolutions', cwd: 'exotic-version'}, async config => { | ||
expect(await getPackageVersion(config, 'left-pad')).toEqual('1.1.1'); | ||
}); | ||
}); | ||
|
||
test.concurrent('install with range resolutions should override versions', (): Promise<void> => { | ||
return runInstall({}, {source: 'resolutions', cwd: 'simple-range'}, async config => { | ||
expect(await getPackageVersion(config, 'left-pad')).toEqual('1.1.1'); | ||
}); | ||
}); | ||
test.concurrent('should warn when resolution entries are incorrrect or incompatible', async (): Promise<void> => { | ||
let error; | ||
|
||
try { | ||
await runInstall({}, {source: 'resolutions', cwd: 'invalid-entries'}); | ||
} catch (e) { | ||
error = e.message; | ||
} | ||
|
||
expect(error).toContain('Resolution field "[email protected]" is incompatible with requested version "left-pad@~1.1.0'); | ||
expect(error).toContain('Resolution field "wrongversion" has an invalid version entry and may be ignored'); | ||
expect(error).toContain('Resolution field "invalidname/" does not end with a valid package name and will be ignored'); | ||
}); |
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 |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
"name": "c", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"left-pad": "~1.1.1" | ||
"left-pad": "~1.1.0" | ||
} | ||
} |
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 @@ | ||
yarn-offline-mirror "./mirror-for-offline" |
Binary file added
BIN
+1.95 KB
__tests__/fixtures/install/resolutions/exotic-version/mirror-for-offline/left-pad-1.1.1.tgz
Binary file not shown.
10 changes: 10 additions & 0 deletions
10
__tests__/fixtures/install/resolutions/exotic-version/package.json
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,10 @@ | ||
{ | ||
"name": "project", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"c": "file:../c-1" | ||
}, | ||
"resolutions": { | ||
"left-pad": "https://github.com/stevemao/left-pad.git#1.1.1" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
__tests__/fixtures/install/resolutions/invalid-entries/package.json
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,12 @@ | ||
{ | ||
"name": "project", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"c": "file:../c-1" | ||
}, | ||
"resolutions": { | ||
"c/**/left-pad": "1.0.0", | ||
"invalidname/": "1.0.0", | ||
"**/left-pad": "wrongversion" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
__tests__/fixtures/install/resolutions/simple-range/package.json
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,10 @@ | ||
{ | ||
"name": "project", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"c": "file:../c-1" | ||
}, | ||
"resolutions": { | ||
"left-pad": "<=1.1.1" | ||
} | ||
} |
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