simplereach / ember-cli-betamax

MIT License
14 stars 4 forks source link

Mocha support? #3

Open jme783 opened 9 years ago

jme783 commented 9 years ago

Does this work with Mocha instead of Qunit?

andremalan commented 9 years ago

Not at the moment, but I'm sure it wouldn't be too hard to switch up insert-cassette to make it happen.

walter commented 9 years ago

I've gotten it working with the following as a replacement for insert-cassette:

// mocha-insert-cassette.js
import {
  startServer,
  stopServer,
  setupServer
} from './fake-server';
import betamaxRecorder from './betamax-recorder';

export default function(cassette){
  beforeEach(function(){
    startServer();

    // if record is not selected, use recordings
    if (!window.recordCassette){
      setupServer(cassette);
    }

    betamaxRecorder.setup();
  });

  afterEach(function(){
    stopServer();

    // if we are not in testem, download new casettes.
    if (window.recordCassette){
      betamaxRecorder.download();
    }
  });
}
// change import line in test-helper to "import insertCassette from './helpers/mocha-insert-cassette';"

In our web UI for the mocha runner, we have added an option to toggle window.recordCassette.