Writing a Sample Test

This first test is just here to introduce Jasmine and Karma, not to be any kind of useful test. This is Jasmine, using ES6 syntax, mostly the arrows:

 describe(​"JavaScript testing"​, () => {
  it(​"works"​, () => {
  expect(1 + 1).toEqual(2)
  })
 })

Jasmine’s syntax is heavily inspired by RSpec, with JavaScript function objects taking the place of Ruby blocks. Like RSpec test suites, Jasmine test suites start with describe. In Jasmine, describe is a method that takes two arguments: a string and a function. The function defines the behavior of an entire test suite.

Inside the describe function argument, individual specs are defined by calls to the function it, which also takes ...

Get Rails 5 Test Prescriptions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.