jeudi 30 juin 2016

How to use a bootstrap file with mocha?

I wish to boostrap mocha.

npm cmd:

 "tests": "mocha assets/test --compilers js:babel-core/register --require assets/test/bootstrap.js",

bootstrap.js

import chai from 'chai'
import chaiEnzyme from 'chai-enzyme'
import {shallow} from 'enzyme'
import React from 'react'


chai.use(chaiEnzyme())
const expect = chai.expect

example file

import Navigation from './../jsx/Navigation.jsx'

describe('<Navigation />', () => {
    const wrapper = shallow(<Navigation />)
    it('render el nav', () => {
        expect(wrapper).to.have.descendants('nav')
    })
})

Gives error:

ReferenceError: shallow is not defined

Not sure why EVERYTHING has to be so difficult with js. How to I do this simplistic thing?

Aucun commentaire:

Enregistrer un commentaire