πŸ€·β€β™€οΈ Expectations
What to expect(), when you're expecting!
There are a set of comparison functions defined in the types/as-pect.d.ts types definition. These comparison functions allow you to inspect object and memory state.
1
class Expectation<T> {
2
constructor(public actual: T) {}
3
not: Expectation<T>;
4
// prototype methods follow
5
}
Copied!
Expectations can be created like this:
1
// create an Expectation with typeof SomeValue`
2
expect(SomeValue);
Copied!
Expectations can be negated like this:
1
// negate an assertion
2
expect(someValue).not.toBe(anotherValue);
3
​
4
// This assertion is effectively:
5
// I don't expect this value to be exactly this value
Copied!
Calling the expect<T>(value: T) function outside of the following functions will result in unexpected behavior:
  • beforeEach()
  • afterEach()
  • beforeAll()
  • afterAll()
  • test()
  • it()
  • throws()
  • itThrows()
If this happens, the entire test suite will fail before it runs in the CLI, and the error description will be reported to the console.
Last modified 2yr ago
Copy link