Bazel's karma.conf is hardcoded to jasmine. How might we enable this to be replaced with other popular options (e.g. mocha or jest)?
The simplest implementation may be to add it to the ts_web_test BUILD rule, but then every package would need to manually specify a framework.
Can we introspect it from package.json? If not, perhaps it can be passed as an option to ts_setup_workspace.
Users could have a mix of assertion libraries (in particular during a migration from one to another).
My proposal is
ts_web_test(framework="mocha")
the framework attribute would default to jasmine, for backwards compatibility.
To support this, we need all the possible frameworks available in node_modules. The simple way is to add them all to https://github.com/bazelbuild/rules_typescript/blob/master/internal/karma/package.json
Does that mean framework: string | Array<string>, so each of these is valid?
ts_web_test(..., framework = "mocha")
ts_web_test(..., framework = ["mocha", "jest"])
@alexeagle So where I'm at now, there's potential we could use something like this. We have a large chunk of our backend stuff building with bazel, but the frontend is still all webpack and npm scripts. The test framework is Jest, though. So that would be a sticking point.
Jest support specifically has been written by @globegitter for another project, we have been frequently discussing upstreaming that lately.
@alexeagle We're looking to use Jest for testing, and we're in the process of moving to Bazel, if you need someone to test it out it's something I'd be happy to start doing.
FWIW I've already been doing browserless testing with domino like https://github.com/bazelbuild/rules_nodejs/pull/1057/files#diff-4716ec1aafc58bef461bb32d4349afe3
but I understand if you have jest imports in your specs then you need it to actually run jest.
we have been frequently discussing upstreaming that lately.
hi :) any update on this?
I haven't heard from @Globegitter in a while, we should catch up on that, I'll try email.
We have a jest_test in the examples now. You can run any arbitrary testing framework.
Most helpful comment
Jest support specifically has been written by @globegitter for another project, we have been frequently discussing upstreaming that lately.