vendredi 29 juin 2018

Can't get Mjacksons Expect module to work in Codepen

I'm trying to follow along learning Redux, and Dan Abramov uses Michael Jacksons expect module, but I can't get it to work in Codepen. I'm under "Pen Settings" > "Javascript" > "Add External Scripts/Pens" and I tried https://npmcdn.com/expect/umd/expect.min.js, https://cdnjs.cloudflare.com/ajax/libs/expect/1.20.2/expect.js, https://unpkg.com/expect@%3C21/umd/expect.min.js and https://wzrd.in/standalone/expect@latest but no matter which I pick, I run the following code which I would expect to throw an exception, and nothing happens in the CodePen console.

function counter(state, action) {
  return state;
}

expect(
counter(0, { type: 'INCREMENT' })
  ).toEqual(1);

expect(
counter(1, { type: 'INCREMENT' })
  ).toEqual(2);

expect(
counter(2, { type: 'DECREMENT' })
  ).toEqual(1);

expect(
counter(1, { type: 'DECREMENT' })
  ).toEqual(0);

console.log('Tests Passed!');

If I use the cloudflare link, I get the following exception in the browser console, but it never loads into the CodePen console.

expect.js:2654 Uncaught Error: Expected 0 to equal 1
    at assert (VM287 expect.js:2654)
    at Expectation.toEqual (VM287 expect.js:172)
    at VM292 pen.js:5

Any idea which is the best to use and why the CodePen console isn't showing the exceptions?

Aucun commentaire:

Enregistrer un commentaire