Skip to content

Commit

Permalink
fix(testing): upgrade deps
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter committed Nov 19, 2024
1 parent 6dbaa98 commit cb31be0
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 216 deletions.
10 changes: 5 additions & 5 deletions testing/_testing_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test("deno")("`test()` is able to detect bun runtime environment", async () => {
Object.assign(globalThis, { Bun: true })
const testcase = test("bun")
expect(testcase).toBeInstanceOf(Function)
await expect(testcase("", () => {}, { __dryrun: true } as testing)).rejects._toThrow(Error, "Not implemented")
await expect(testcase("", () => {}, { __dryrun: true } as testing)).rejects.toThrow(Error, "Not implemented")
} finally {
delete (globalThis as testing).Bun
}
Expand All @@ -51,23 +51,23 @@ test("deno")("`test()` is able to detect node runtime environment", async () =>
Object.assign(globalThis, { process: { versions: { node: true } } })
const testcase = test("node")
expect(testcase).toBeInstanceOf(Function)
await expect(testcase("", () => {}, { __dryrun: true } as testing)).rejects._toThrow(Error, "Not implemented")
await expect(testcase("", () => {}, { __dryrun: true } as testing)).rejects.toThrow(Error, "Not implemented")
} finally {
Object.assign(globalThis, { Deno: _Deno })
}
})

test("deno")("`install()` resolves and install dependencies", () => {
for (const _ of [1, 2]) {
expect(() => install([null as testing], import.meta.filename!)).not._toThrow()
expect(() => install([null as testing], import.meta.filename!)).not.toThrow()
}
expect(cache.has(`null:${import.meta.filename}`)).toBe(true)
}, { permissions: { run: ["deno"] } })

for (const runtime of Object.keys(available) as runtime[]) {
test("deno")(`\`testcase()\` is able to run tests on ${runtime} runtime`, async () => {
const filename = fromFileUrl(import.meta.resolve("./_stub_test.ts"))
await expect(testcase(runtime, filename, "test() stub throws error", () => {})).not.resolves._toThrow()
await expect(testcase(runtime, filename, "test() stub throws error", () => {})).not.resolves.toThrow()
}, { permissions: { run: "inherit" } })
}

Expand All @@ -85,4 +85,4 @@ test("deno")("`test()` restore environment after applying custom environment", (
expect(Deno.env.get("TEST_BAR")).toBe("baz")
}, { permissions: { env: ["TEST_FOO", "TEST_BAR"] } })

test()("`placeholder()` use default runtimes when none is specified", () => void expect(placeholder).not._toThrow())
test()("`placeholder()` use default runtimes when none is specified", () => void expect(placeholder).not.toThrow())
132 changes: 66 additions & 66 deletions testing/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions testing/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface ExtendedExpected<IsAsync = false> extends Expected<IsAsync> {
* @experimental This method may be renamed to `toThrow()` directly without being marked as breaking change.
*/
// deno-lint-ignore no-explicit-any
_toThrow: <E extends Error = Error>(error?: string | RegExp | E | (new (...args: any[]) => E), message?: string | RegExp) => void
toThrow: <E extends Error = Error>(error?: string | RegExp | E | (new (...args: any[]) => E), message?: string | RegExp) => void
/**
* Asserts a value matches the given predicate.
*
Expand Down Expand Up @@ -373,7 +373,7 @@ function isType(value: testing, type: TypeOf, { nullable = false } = {}) {
}

_expect.extend({
_toThrow(context, error, message) {
toThrow(context, error, message) {
// deno-lint-ignore no-explicit-any
type ErrorConstructor = new (...args: any[]) => Error
if (typeof context.value === "function") {
Expand Down
Loading

0 comments on commit cb31be0

Please sign in to comment.