-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(expect,internal,testing): support
expect.assertions
(#6032)
Co-authored-by: Yoshiya Hinosawa <[email protected]> Co-authored-by: Asher Gomez <[email protected]>
- Loading branch information
1 parent
10ee73d
commit ed79df4
Showing
9 changed files
with
246 additions
and
52 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. | ||
|
||
import { describe, it, test } from "@std/testing/bdd"; | ||
import { expect } from "./expect.ts"; | ||
|
||
Deno.test("expect.hasAssertions() API", () => { | ||
describe("describe suite", () => { | ||
// FIXME(eryue0220): This test should through `toThrowErrorMatchingSnapshot` | ||
it("should throw an error", () => { | ||
expect.hasAssertions(); | ||
}); | ||
|
||
it("should pass", () => { | ||
expect.hasAssertions(); | ||
expect("a").toEqual("a"); | ||
}); | ||
}); | ||
|
||
it("it() suite should pass", () => { | ||
expect.hasAssertions(); | ||
expect("a").toEqual("a"); | ||
}); | ||
|
||
// FIXME(eryue0220): This test should through `toThrowErrorMatchingSnapshot` | ||
test("test suite should throw an error", () => { | ||
expect.hasAssertions(); | ||
}); | ||
|
||
test("test suite should pass", () => { | ||
expect.hasAssertions(); | ||
expect("a").toEqual("a"); | ||
}); | ||
}); | ||
|
||
Deno.test("expect.assertions() API", () => { | ||
test("should pass", () => { | ||
expect.assertions(2); | ||
expect("a").not.toBe("b"); | ||
expect("a").toBe("a"); | ||
}); | ||
|
||
// FIXME(eryue0220): This test should through `toThrowErrorMatchingSnapshot` | ||
test("should throw error", () => { | ||
expect.assertions(1); | ||
expect("a").not.toBe("b"); | ||
expect("a").toBe("a"); | ||
}); | ||
|
||
it("redeclare different assertion count", () => { | ||
expect.assertions(3); | ||
expect("a").not.toBe("b"); | ||
expect("a").toBe("a"); | ||
expect.assertions(2); | ||
}); | ||
|
||
test("expect no assertions", () => { | ||
expect.assertions(0); | ||
}); | ||
|
||
// FIXME(eryue0220): This test should through `toThrowErrorMatchingSnapshot` | ||
it("should throw an error", () => { | ||
expect.assertions(2); | ||
}); | ||
}); |
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
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
Oops, something went wrong.