Open Arcanemagus opened 7 years ago
This might help. https://github.com/keplersj/atom-test-runner-jest
@keplersj Cleaned up the list, looks like yours isn't (yet?) published on NPM though. Somebody else also built a Jest runner, but their build is failing so I have no idea how usable it is lol.
It's live. I've used it for language-crystal to simply the tokenization tests with snapshots. https://github.com/crystal-lang-tools/language-crystal
atom-jasmine3-test-runner lets you write new tests in Jasmine 3.x while keeping old tests in Jasmine 1.3 while transitioning.
If anyone's looking for an example of code coverage in an Atom package, look no further than linter-swiftlint
.
How do you run the tests on linter-swiftlint?
When I try to run window:run-package-specs
the window locks up, and when I run atom --test spec
I get "No tests found"
Hmmmm, atom --test spec
is what the test script and the ci builds run, so that should be working. I don't have a mac to test on so I'll leave it to @keplersj to answer further 🤷♂️.
window:run-package-specs
won't work because atom-test-runner-jest
does not currently implement that portion of the Atom test runner functionality. A PR if you're interested would be very much appreciated. Running apm test
, atom --test .
, or atom --test spec
should all work as long as you have -spec.js
files in the spec
. atom-test-runner-jest
is simply configuring the atom
global and passing the rest off to the Jest CLI. If your not seeing tests picked up and run from there it's most likely due to Jest configuration.
atom --test spec
should all work as long as you have-spec.js
files in thespec
do the .ts
files need to be transpiled first?
Not when using jest-prest-atom
and atom-typescript-transpiler
, like linter-swiftlint
. jest-preset-atom
is configured to make use of Atom's builtin compile-cache functionality.
What am I doing wrong?
npm install
apm install
npm test
C:\Users\tjbrix\Documents\projects\GitHub\linter-swiftlint>npm test
> linter-swiftlint@1.3.1 test C:\Users\tjbrix\Documents\projects\GitHub\linter-swiftlint
> atom --test spec
No tests found
In C:\Users\tjbrix\Documents\projects\GitHub\linter-swiftlint
9 files checked.
testMatch: **/__tests__/**/*.(js|jsx|json|node|ts|tsx|coffee|litcoffee|coffee.md),**/?(*.)(spec|test).(js|jsx|json|node|ts|tsx|coffee|litcoffee|coffee.md),**/spec/**/*-spec.(js|jsx|json|node|ts|tsx|coffee|litcoffee|coffee.md) - 1 match
testPathIgnorePatterns: \\node_modules\\ - 9 matches
Pattern: C:\Users\tjbrix\Documents\projects\GitHub\linter-swiftlint\spec - 0 matches
Guess I'll have to break out the Windows and do some debugging. My first guess is that I'm doing something in jest-preset-atom
that is incompatible on Windows.
Seems to be something with Windows. I setup an Ubuntu VM and did the same steps and everything worked.
@UziTech I've just replicated your issue. Investigating further.
@UziTech I think I've found a potential solution. Going to verify it doesn't break macOS and Linux.
@UziTech Fixed in atom-test-runnner-jest@0.2.3
it works 🎉
Code Coverage
The Jasmine 1.3 based test framework built into Atom that most packages use is not only quite out of date, but doesn't support generating code coverage support of a package.
An alternative test framework that supports generating code coverage reports should be looked into.
Atom supports running custom test runners with the
atomTestRunner
key inpackage.json
. This was introduced in https://github.com/atom/atom/pull/8968, although it looks like the functionality may have changed from what is documented there.Potential frameworks
Mocha
atom-mocha-test-runner
Example usage can be found in the atom/github repo (note, tagged link, check for newer version later).Jest
atom-test-runner-jest
atom-jest-test-runner
The build for this is failing currently, not exactly a good sign for it's usability.