-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* updating package with child peerDependency doesn't keep old version * [autofix.ci] apply automated fixes * fixed TODO test * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
4611b84
commit 1526366
Showing
2 changed files
with
134 additions
and
56 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
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 |
---|---|---|
|
@@ -180,6 +180,87 @@ test("dependency from root satisfies range from dependency", async () => { | |
expect(await exited).toBe(0); | ||
}); | ||
|
||
test("peerDependency in child npm dependency should not maintain old version when package is upgraded", async () => { | ||
await writeFile( | ||
join(packageDir, "package.json"), | ||
JSON.stringify({ | ||
name: "foo", | ||
version: "1.0.0", | ||
dependencies: { | ||
"peer-deps-fixed": "1.0.0", | ||
"no-deps": "1.0.0", | ||
}, | ||
}), | ||
); | ||
|
||
var { stdout, stderr, exited } = spawn({ | ||
cmd: [bunExe(), "install"], | ||
cwd: packageDir, | ||
stdout: null, | ||
stdin: "pipe", | ||
stderr: "pipe", | ||
env, | ||
}); | ||
|
||
expect(stderr).toBeDefined(); | ||
var err = await new Response(stderr).text(); | ||
expect(stdout).toBeDefined(); | ||
var out = await new Response(stdout).text(); | ||
expect(err).toContain("Saved lockfile"); | ||
expect(err).not.toContain("not found"); | ||
expect(err).not.toContain("error:"); | ||
expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ | ||
"", | ||
" + [email protected]", | ||
" + [email protected]", | ||
"", | ||
" 2 packages installed", | ||
]); | ||
expect(await file(join(packageDir, "node_modules", "no-deps", "package.json")).json()).toEqual({ | ||
name: "no-deps", | ||
version: "1.0.0", | ||
} as any); | ||
expect(await exited).toBe(0); | ||
|
||
await writeFile( | ||
join(packageDir, "package.json"), | ||
JSON.stringify({ | ||
name: "foo", | ||
version: "1.0.0", | ||
dependencies: { | ||
"peer-deps-fixed": "1.0.0", | ||
"no-deps": "1.0.1", // upgrade the package | ||
}, | ||
}), | ||
); | ||
|
||
({ stdout, stderr, exited } = spawn({ | ||
cmd: [bunExe(), "install"], | ||
cwd: packageDir, | ||
stdout: null, | ||
stdin: "pipe", | ||
stderr: "pipe", | ||
env, | ||
})); | ||
|
||
err = await new Response(stderr).text(); | ||
out = await new Response(stdout).text(); | ||
expect(err).not.toContain("not found"); | ||
expect(err).not.toContain("error:"); | ||
expect(await file(join(packageDir, "node_modules", "no-deps", "package.json")).json()).toEqual({ | ||
name: "no-deps", | ||
version: "1.0.1", | ||
} as any); | ||
expect(await exists(join(packageDir, "node_modules", "peer-deps-fixed", "node_modules"))).toBeFalse(); | ||
expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ | ||
"", | ||
" + [email protected]", | ||
"", | ||
" 1 package installed", | ||
]); | ||
expect(await exited).toBe(0); | ||
}); | ||
|
||
test("package added after install", async () => { | ||
await writeFile( | ||
join(packageDir, "package.json"), | ||
|
@@ -3997,48 +4078,46 @@ describe("yarn tests", () => { | |
expect(await exited).toBe(0); | ||
}); | ||
|
||
test.todo( | ||
"it should install in such a way that two identical packages with different peer dependencies are different instances", | ||
async () => { | ||
await writeFile( | ||
join(packageDir, "package.json"), | ||
JSON.stringify({ | ||
name: "foo", | ||
version: "1.0.0", | ||
dependencies: { | ||
"provides-peer-deps-1-0-0": "1.0.0", | ||
"provides-peer-deps-2-0-0": "1.0.0", | ||
}, | ||
}), | ||
); | ||
test("it should install in such a way that two identical packages with different peer dependencies are different instances", async () => { | ||
await writeFile( | ||
join(packageDir, "package.json"), | ||
JSON.stringify({ | ||
name: "foo", | ||
version: "1.0.0", | ||
dependencies: { | ||
"provides-peer-deps-1-0-0": "1.0.0", | ||
"provides-peer-deps-2-0-0": "1.0.0", | ||
}, | ||
}), | ||
); | ||
|
||
var { stdout, stderr, exited } = spawn({ | ||
cmd: [bunExe(), "install"], | ||
cwd: packageDir, | ||
stdout: null, | ||
stdin: "pipe", | ||
stderr: "pipe", | ||
env, | ||
}); | ||
var { stdout, stderr, exited } = spawn({ | ||
cmd: [bunExe(), "install"], | ||
cwd: packageDir, | ||
stdout: null, | ||
stdin: "pipe", | ||
stderr: "pipe", | ||
env, | ||
}); | ||
|
||
var err = await new Response(stderr).text(); | ||
var out = await new Response(stdout).text(); | ||
expect(err).toContain("Saved lockfile"); | ||
expect(err).not.toContain("error:"); | ||
expect(err).not.toContain("not found"); | ||
expect(err).not.toContain("incorrect peer dependency"); | ||
expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ | ||
"", | ||
" + [email protected]", | ||
" + [email protected]", | ||
"", | ||
" 5 packages installed", | ||
]); | ||
expect(await exited).toBe(0); | ||
var err = await new Response(stderr).text(); | ||
var out = await new Response(stdout).text(); | ||
expect(err).toContain("Saved lockfile"); | ||
expect(err).not.toContain("error:"); | ||
expect(err).not.toContain("not found"); | ||
expect(err).not.toContain("incorrect peer dependency"); | ||
expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ | ||
"", | ||
" + [email protected]", | ||
" + [email protected]", | ||
"", | ||
" 5 packages installed", | ||
]); | ||
expect(await exited).toBe(0); | ||
|
||
await writeFile( | ||
join(packageDir, "test.js"), | ||
`console.log( | ||
await writeFile( | ||
join(packageDir, "test.js"), | ||
`console.log( | ||
require("provides-peer-deps-1-0-0").dependencies["peer-deps"] === | ||
require("provides-peer-deps-2-0-0").dependencies["peer-deps"] | ||
); | ||
|
@@ -4086,24 +4165,23 @@ describe("yarn tests", () => { | |
}, | ||
}) | ||
);`, | ||
); | ||
); | ||
|
||
({ stdout, stderr, exited } = spawn({ | ||
cmd: [bunExe(), "test.js"], | ||
cwd: packageDir, | ||
stdout: null, | ||
stdin: "pipe", | ||
stderr: "pipe", | ||
env, | ||
})); | ||
({ stdout, stderr, exited } = spawn({ | ||
cmd: [bunExe(), "test.js"], | ||
cwd: packageDir, | ||
stdout: null, | ||
stdin: "pipe", | ||
stderr: "pipe", | ||
env, | ||
})); | ||
|
||
err = await new Response(stderr).text(); | ||
out = await new Response(stdout).text(); | ||
expect(out).toBe("true\ntrue\ntrue"); | ||
expect(err).toBeEmpty(); | ||
expect(await exited).toBe(0); | ||
}, | ||
); | ||
err = await new Response(stderr).text(); | ||
out = await new Response(stdout).text(); | ||
expect(out).toBe("true\ntrue\nfalse\n"); | ||
expect(err).toBeEmpty(); | ||
expect(await exited).toBe(0); | ||
}); | ||
|
||
test("it should install in such a way that two identical packages with the same peer dependencies are the same instances (simple)", async () => { | ||
await writeFile( | ||
|