oclif / fancy-test

extends mocha with helpful, chainable extensions

Home Page:https://npmjs.com/package/fancy-test

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Document how to use w/ jest

G-Rath opened this issue · comments

I'm interested in using oclif in a jest project; ideally I'd like to use jest code as much as possible (i.e it & describe), but for now I'm looking into fancy-test to get going fast.

In the readme it says:

It should be compatible with other testing libraries as well (e.g. jest), but may require a couple small changes. If you're interested, try it out and let me know if it works.

But I can't find any evidence on how to get it working w/ jest.

I'm opening this issue for both assistance & as documentation, as I'll include details on how to go about it if I manage to get it working myself :)

I'd like to second the call for some jest experimentation. A bit of interesting context is the brief discussion that takes place around testing in the Future of Oclif presentation.

Here is someone's blog post where they are entirely reinventing the oclif testing wheel. I think they are fighting some problems that are already solved within fancy-test.

I think there are a few moving pieces here that need to be considered:

  • Should fancy-test continue to use the jquery like function chaining syntax in the long term? I think part of @G-Rath's ask here is a move away from the focus on function chaining. I too would prefer more of a rspec style.
  • Is it possible to support jest's specific setup and teardown needs alongside mocha's or do these need to be separate projects/ architectures? Doing a short search for mocha in the codebase most of the mocha specific implementation appears to be contained within src/base.ts and src/types.ts

I recently discovered oclif and was also interested in using jest for testing as I have a lot of experience with jest and not as much with mocha/chai. After a lot of experimentation, I was able to get a minimal hello-world example working: https://github.com/RTongue/jest-test/tree/oclif-jest-test

TBD if this will work in more complex scenarios.