We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Add support of Assertion Functions to earl assertions.
Motivation: The next code does not pass types validation:
import { suite, test } from "mocha"; import { expect } from 'earl' type UnionType = {status: 400} | {status: 200, body: string} var testObject: UnionType = {status: 200, body: "hello"}; suite("reports", () => { test("create report", async () => { expect(testObject.status).toEqual(200); expect(testObject.body).toEqual("hello"); }); });
On line 11 the error is shown: Property 'body' does not exist on type 'UnionType'. Property 'body' does not exist on type '{ status: 400; }'.
It doesn't work as expected because earl do not support Assertion Functions But if i use workaround with asserts:
earl
asserts
import { suite, test } from "mocha"; import { expect } from 'earl' type UnionType = {status: 400} | {status: 200, body: string} var testObject: UnionType = {status: 200, body: "hello"}; suite("reports", () => { test("create report", async () => { expect_toBe(testObject.status, 200); expect(testObject.body).toEqual("hello"); }); }); function expect_toBe<T>(arg: any, value: T): asserts arg is T { expect(arg).toEqual(value); }
it works fine.
Is it possible to add such assertions to earl functions definitions?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Request:
Add support of Assertion Functions to earl assertions.
Motivation:
The next code does not pass types validation:
On line 11 the error is shown:
Property 'body' does not exist on type 'UnionType'.
Property 'body' does not exist on type '{ status: 400; }'.
It doesn't work as expected because
earl
do not support Assertion FunctionsBut if i use workaround with
asserts
:it works fine.
Is it possible to add such assertions to
earl
functions definitions?The text was updated successfully, but these errors were encountered: