1

I am planning to use either CoffeeScript or TypeScript in one of my project which transcompiles to JavaScript. And I would like to use Jasmine/Mocha unit testing framework. But I could not find proper answers to below questions in google.

  1. Which is correct, testing complied JavaScript or CoffeScript/TypeScript and Why ?
  2. Does it make sense to use TypeScript/CoffeeScript to write testcases as well ?
2
  • 2
    Depending upon what you are doing, you may never need to see JavaScript. Express, Sails, Meteor, Browserify, NodeUnit, WebStorm, and others (don't know about Jasmine/Mocha) will compile it for you including source maps for debugging such that you rarely need to see the JavaScript. So, my answer to both 1 and 2 is to try to stay in CoffeeScript/Typescript for everything and try (you won't quite succeed) to think about JavaScript as much as you think about machine language when you are using a language like C. Commented Nov 26, 2014 at 2:59
  • 1
    It completely makes sense to use TS or CS for unit testing. If you are using TypeScript, some framework exist: tsUnit, Oscar etc. These frameworks are closer to static languages than Jasmine or fellows, which are inherited from Rails tools. Commented Dec 31, 2014 at 6:29

2 Answers 2

2
  1. You have to compile CoffeeScript/TypeScript in order to run it. That includes testing. So, yes, you test the compiled version. You may want to have different (smaller) compilation units for the unit tests if compiling the whole thing takes too long.

  2. Sure. Then you get all the advantages you chose these languages for.

Sign up to request clarification or add additional context in comments.

Comments

1

My doubt is which will make sense testing complied JavaScript or CoffeScript/TypeScript and Why

Either will work fine.

Does it make sense to use TypeScript/CoffeeScript to write testcases as well ?

Yes it does. Stick and a language an run with it. For TypeScript you might find this quick sample as useful : https://github.com/TypeStrong/tsproj

code: https://github.com/TypeStrong/tsproj/tree/master/src/lib tests: https://github.com/TypeStrong/tsproj/tree/master/src/test

I don't have a better sample that is still simple :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.