Unable to get started with plugin

17 views
Skip to first unread message

Timothy Caraballo

unread,
Feb 10, 2017, 10:50:42 PM2/10/17
to Chai.js
I'd like to start making plugins, but I'm obviously missing something. The two files are below. Running the test  below shows only the log of "Setting it up", but the attempted usage results in undefined is not a constructor (evaluating 'expect({}).to.something()') because something is not defined.
What am I missing?

// plugin.js
export default (chai, utils) => {
  console.log('Setting it up')

  chai.Assertion.addMethod('something', () => {
    console.log('Doing something')
    // this.assert would be here...
  })
}


import chai from 'chai'
import plugin from './plugin'

chai.use(plugins)

describe('chai plugin', function() {
  it('should do something', function() {
    expect({}).to.something()
  })
})



Reply all
Reply to author
Forward
0 new messages