So... I would like to be able to use coffeescript without having to add the ".coffee" extension in my requires (in the lib code, not the test code).
I would guess that in my test a require('coffee-script/register')
would work -- but I'd be wrong. :)
For example, I'd like to get this working:
util.coffee
:
module.exports=
log: (msg)->
console.log "LOG", msg
sum.coffee
:
{ log }= require './util'
module.exports= (a,b)->
log "sum it"
a + b
__tests__/sum-test.coffee
:
jest.dontMock '../sum.coffee'
sum= require '../sum.coffee'
describe 'Sum', ->
it 'should sum stuff', ->
expect sum(2,2)
.toBe 4
Currently, you'd have to do this (Note the added ".coffee
"):
util.coffee
:
module.exports=
log: (msg)->
console.log "LOG", msg
sum.coffee
:
{ log }= require './util.coffee' # <= would rather not pollute my lib code like this
module.exports= (a,b)->
log "sum it"
a + b
__tests__/sum-test.coffee
:
jest.dontMock '../sum.coffee'
sum= require '../sum.coffee'
describe 'Sum', ->
it 'should sum stuff', ->
expect sum(2,2)
.toBe 4
Am I being picky? Yes. But that doesn't mean that it wouldn't be nice.
I'm packaging my project for the client via Browserify. Is there an easy-ish way to accomplish this that I'm missing, or would it be more involved?