question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question - Adding support for PureScript

See original GitHub issue

Hello! I recently discovered nyc, and before anything, I’d like to thank all the contributors for the work you’ve done, it is awesome ❤️

I’d like to know if there is support for non-mainstream languages, like PureScript, that compile to JavaScript. I’ve tried using nyc with a PureScript project, but the coverage reported is not quite true.

I know that nyc supports source mapping, and that’s what I used, but it reports no coverage.

The code that I have written for a test in PureScript is like this one:

module Test.Main where

import Prelude

import Effect (Effect)
import Test.Spec (describe, it)
import Test.Spec.Assertions (shouldEqual)
import Test.Spec.Reporter.Console (consoleReporter)
import Test.Spec.Runner (run)
import Components.Foo (foo)

main :: Effect Unit
main = run [consoleReporter] do
  describe "something" do
    it "tests" do
      foo `shouldEqual` 42

which compiles to the following JavaScript

// Generated by purs version 0.12.5
"use strict";
var Components_Foo = require("../Components.Foo/index.js");
var Data_Eq = require("../Data.Eq/index.js");
var Data_Show = require("../Data.Show/index.js");
var Test_Spec = require("../Test.Spec/index.js");
var Test_Spec_Assertions = require("../Test.Spec.Assertions/index.js");
var Test_Spec_Reporter_Console = require("../Test.Spec.Reporter.Console/index.js");
var Test_Spec_Runner = require("../Test.Spec.Runner/index.js");
var main = Test_Spec_Runner.run([ Test_Spec_Reporter_Console.consoleReporter ])(Test_Spec.describe("something")(Test_Spec.it("tests")(Test_Spec_Assertions.shouldEqual(Data_Show.showInt)(Data_Eq.eqInt)(Components_Foo.foo)(42))));
module.exports = {
    main: main
};
//# sourceMappingURL=index.js.map

The tested source file is Components.Foo:

module Components.Foo where

foo :: Int
foo = 42

which compiles to:

// Generated by purs version 0.12.5
"use strict";
var foo = 42;
module.exports = {
    foo: foo
};
//# sourceMappingURL=index.js.map

In theory, it should report that I’m using at least foo. But it reports 0% of coverage:

image

image

Is there something that I can do on my side to allow using nyc with PureScript? Perhaps adding some hook to the test framework or something?

Link to demo repo

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
NickSeagullcommented, Aug 27, 2020

Didn’t touch this apart from the quick tests I did when openened the issue sorry, perhaps some other user can give more insights

1reaction
andys8commented, Sep 28, 2020

Hey, I wanted to give it a try with:

nyc --clean -e ".purs" spago test  --purs-args "-g sourcemaps"

(spago changed the way you pass args to purs)

I end up with a large list containing all foreign imports and dependencies. Hard to tell if the result is still fine and using sourcemaps correctly.

Did you end up with using this to produce statistics? How did you use nycs configuration arguments to use output for sourcemaps, but ignore dependencies?

nyc --clean -x ".spago/**" -x "**/foreign.js" -e ".purs" spago test --purs-args "-g sourcemaps"

^ this looks promising but still showing some js files, and missing some tested purescript files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started - PureScript by Example
In this chapter, we'll set up a working PureScript development environment, solve some exercises, and use the tests provided with this book to...
Read more >
Will Purescript be added as a supported language? - Codecademy ...
Hi: I'm planning to get my 13 year old started with codeacademy, and I want him to start with a language with a...
Read more >
Can you consider direct support for the PureScript | Elm
Hello, It is possible to add suport for directly interacting with languages like PureScript, Elm and also being able to use web componenets ......
Read more >
PureScript - All types appearing in instance declarations must ...
And the root reason is that PureScript just doesn't support instances for records. Sorry, tough luck. No way to do this.
Read more >
Read PureScript by Example | Leanpub
It features lightweight syntax, which allows us to write very expressive code which is still clear and readable. It uses a rich type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found