You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another enhancement request: I was wondering how you'd feel about replacing Mocha with Jest?
Motivation
Chai's API can be a little inconsistent with whether you should use brackets or not after assertions. Jest's API is straight-forward, no having to guess the correct combination of nested property names, and every assertion is a function, not a property getter, so you always use brackets. e.g. expect(thing).toBeTruthy().
Support for spying on mock functions comes out of box. No need to use a separate library like Sinon. Naive example:
Support for mocking modules out of the box. No need to use a separate library like mockery. Unlike mockery you don't need to ensure your mock is registered before the library is required in the code that you're testing.
Comes with Instanbul support built-in, allowing you to easily track code-coverage and even fail when minimum thresholds for functions, statements, branches and lines are not met.
One test library to rule them all! 💍
Indirectly related: Also wanted to ask how you'd feel about putting the tests in the same directory as the files being tested.
This has the following advantages:
Makes it clear that foo.ts is not tested when it doesn't have an accompanying foo.test.ts file right next to it.
No need to maintain a mirrored directory structure of your tests.
The text was updated successfully, but these errors were encountered:
(I agree re: Chai's BDD API, but they also offer a "TDD" API which uses classic single-function assertions.)
I'd prefer to keep the tests in a separate directory for now, it makes it easier to exclude test files from the TSC config and published artifacts. The code coverage report could serve to tell us if a file is tested.
Okay, cool. I might convert it and shoot through a PR when I have some time.
No worries at test location, though I will say...
Don't forget that tsconfig has an exclude glob option.
Also, the ts-jest plugin for jest runs directly against the .ts files without generating .js files so test output files never pollute your artefacts directory.
Imho, it's super nice when creating a component to have a folder for the component, with code, the view, styles and tests all in same location. Much less jumping around the project to find related files.
Another enhancement request: I was wondering how you'd feel about replacing Mocha with Jest?
Motivation
Chai's API can be a little inconsistent with whether you should use brackets or not after assertions. Jest's API is straight-forward, no having to guess the correct combination of nested property names, and every assertion is a function, not a property getter, so you always use brackets. e.g.
expect(thing).toBeTruthy()
.Support for spying on mock functions comes out of box. No need to use a separate library like Sinon. Naive example:
Support for mocking modules out of the box. No need to use a separate library like mockery. Unlike mockery you don't need to ensure your mock is registered before the library is required in the code that you're testing.
Comes with Instanbul support built-in, allowing you to easily track code-coverage and even fail when minimum thresholds for functions, statements, branches and lines are not met.
One test library to rule them all! 💍
Indirectly related: Also wanted to ask how you'd feel about putting the tests in the same directory as the files being tested.
This has the following advantages:
Makes it clear that
foo.ts
is not tested when it doesn't have an accompanyingfoo.test.ts
file right next to it.No need to maintain a mirrored directory structure of your tests.
The text was updated successfully, but these errors were encountered: