Unit-testing-tools for bootprint-projects
npm install bootprint-unit-testing
Consider a bootprint-module that uses the following Handlebarse-template as index.html.hbs
A test can be written like this:
/*!
* bootprint-unit-testing <https://github.com/bootprint/bootprint-unit-testing>
*
* Copyright (c) 2017 Nils Knappmeier.
* Released under the MIT license.
*/
/* global describe */
/* global it */
/* global before */
// /* global xit */
'use strict'
var expect = require('chai').expect
var core = require('bootprint-unit-testing')(require('./module.js'), __dirname)
describe('The bootprint-unit-testing module', function () {
this.timeout(10000)
var context = {}
before(function () {
return core.run({ name: 'Nils' }, context)
})
it('The output should contain the name in a <p>-tag', function () {
expect(context.$('p').html()).to.contain('Nils')
})
})
The test will run bootprint with the given module and verify the generated HTML using the cheerio library.
The bootprint-unit-testing module
✓ The output should contain the name in a <p>-tag
1 passing (376ms)
bootprint-unit-testing
is published under the MIT-license.
See LICENSE.md for details.
For release notes, see CHANGELOG.md
See CONTRIBUTING.md.