CoffeeScript Online IDE & Code Editor for Technical Interviews
Running CoffeeScript 2.6 under Node.js v16 - IntelliSense is not available
CoffeeScript in CoderPad just runs on top of the JavaScript environment, the only difference being that we do not run CoffeeScript with the --harmony
flag.
We also have an array of interesting npm packages available for your use:
- underscore and lodash for many useful functional helpers.
- chai, sinon, sinon-chai, and mocha testing libraries.
Here’s a quick example of how to use sinon
and chai
:
chai = require('chai')
sinon = require('sinon')
sinonChai = require('sinon-chai')
hello = (name, cb) ->
cb 'hello ' + name
return
chai.should()
chai.use sinonChai
cb = sinon.spy()
hello 'world', cb
cb.should.have.been.calledWith 'this test should fail'
Code language: CoffeeScript (coffeescript)
as well as mocha
:
Mocha = require('mocha')
assert = require('assert')
mocha = new Mocha
# Bit of a hack, sorry!
mocha.suite.emit 'pre-require', this, 'solution', mocha
describe 'Test suite', ->
it 'should work', ->
assert true
mocha.run()
Code language: CoffeeScript (coffeescript)
- You can use async, request, and isomorphic-fetch for making async HTTP a little more convenient.
- q and bluebird are promise libraries to help make managing async in general easier.
- jsdom is a library for mimicking an HTML DOM within our JS environment. Useful if you want to manipulate elements without using our full HTML/CSS/JS environment.