feat: introduce APIs to update envs from tests and recursive resolution

This commit is contained in:
Andrew Bastin
2022-02-19 02:20:28 +05:30
parent 3cb47d3812
commit 59c6e21636
20 changed files with 1392 additions and 168 deletions

View File

@@ -8,15 +8,21 @@ describe("execPreRequestScript", () => {
`
pw.env.set("bob", "newbob")
`,
[
{ key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
]
{
global: [],
selected: [
{ key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
],
}
)()
).resolves.toEqualRight([
{ key: "bob", value: "newbob" },
{ key: "foo", value: "bar" },
])
).resolves.toEqualRight({
global: [],
selected: [
{ key: "bob", value: "newbob" },
{ key: "foo", value: "bar" },
],
})
})
test("fails if the key is not a string", () => {
@@ -25,10 +31,13 @@ describe("execPreRequestScript", () => {
`
pw.env.set(10, "newbob")
`,
[
{ key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
]
{
global: [],
selected: [
{ key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
],
}
)()
).resolves.toBeLeft()
})
@@ -39,10 +48,13 @@ describe("execPreRequestScript", () => {
`
pw.env.set("bob", 10)
`,
[
{ key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
]
{
global: [],
selected: [
{ key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
],
}
)()
).resolves.toBeLeft()
})
@@ -51,12 +63,15 @@ describe("execPreRequestScript", () => {
return expect(
execPreRequestScript(
`
pw.env.set("bob",
pw.env.set("bob",
`,
[
{ key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
]
{
global: [],
selected: [
{ key: "bob", value: "oldbob" },
{ key: "foo", value: "bar" },
],
}
)()
).resolves.toBeLeft()
})
@@ -67,8 +82,11 @@ describe("execPreRequestScript", () => {
`
pw.env.set("foo", "bar")
`,
[]
{ selected: [], global: [] }
)()
).resolves.toEqualRight([{ key: "foo", value: "bar" }])
).resolves.toEqualRight({
global: [],
selected: [{ key: "foo", value: "bar" }],
})
})
})