AtomLinter / Meta

This is where we discuss the org itself
1 stars 0 forks source link

Look into code coverage #19

Open Arcanemagus opened 7 years ago

Arcanemagus commented 7 years ago

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 in package.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

Jest

keplersj commented 6 years ago

This might help. https://github.com/keplersj/atom-test-runner-jest

Arcanemagus commented 6 years ago

@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.

keplersj commented 6 years ago

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

keplersj commented 6 years ago

https://www.npmjs.com/package/atom-test-runner-jest

UziTech commented 6 years ago

atom-jasmine3-test-runner lets you write new tests in Jasmine 3.x while keeping old tests in Jasmine 1.3 while transitioning.

keplersj commented 6 years ago

If anyone's looking for an example of code coverage in an Atom package, look no further than linter-swiftlint.

UziTech commented 6 years ago

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"

Arcanemagus commented 6 years ago

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 🤷‍♂️.

keplersj commented 6 years ago

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.

UziTech commented 6 years ago

atom --test spec should all work as long as you have -spec.js files in the spec

do the .ts files need to be transpiled first?

keplersj commented 6 years ago

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.

UziTech commented 6 years ago

What am I doing wrong?

  1. I cloned the repo
  2. ran npm install
  3. ran apm install
  4. ran 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
keplersj commented 6 years ago

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.

UziTech commented 6 years ago

Seems to be something with Windows. I setup an Ubuntu VM and did the same steps and everything worked.

keplersj commented 6 years ago

@UziTech I've just replicated your issue. Investigating further.

keplersj commented 6 years ago

@UziTech I think I've found a potential solution. Going to verify it doesn't break macOS and Linux.

keplersj commented 6 years ago

@UziTech Fixed in atom-test-runnner-jest@0.2.3

UziTech commented 6 years ago

it works 🎉