├── .babelrc ├── .eslintrc ├── .gitignore ├── .travis.yml ├── README.md ├── karma.conf.js ├── modules ├── TestUtils.js ├── __tests__ │ ├── .eslintrc │ ├── toHaveAttribute-test.js │ ├── toHaveAttributes-test.js │ ├── toHaveText-test.js │ ├── toNotHaveAttribute-test.js │ ├── toNotHaveAttributes-test.js │ └── toNotHaveText-test.js └── index.js ├── package.json ├── scripts ├── build.js └── release.js ├── tests.webpack.js └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "es2015" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "plugins": [ 4 | "import" 5 | ], 6 | "env": { 7 | "es6": true, 8 | "node": true, 9 | "browser": true 10 | }, 11 | "extends": [ 12 | "eslint:recommended", 13 | "plugin:import/errors" 14 | ], 15 | "rules": { 16 | "array-bracket-spacing": [ 2, "always" ], 17 | "semi": [ 2, "never" ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib 2 | umd 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - stable 5 | branches: 6 | only: 7 | - master 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # expect-element [![Travis][build-badge]][build] [![npm package][npm-badge]][npm] 2 | 3 | [build-badge]: https://img.shields.io/travis/mjackson/expect-element/master.svg?style=flat-square 4 | [build]: https://travis-ci.org/mjackson/expect-element 5 | 6 | [npm-badge]: https://img.shields.io/npm/v/expect-element.svg?style=flat-square 7 | [npm]: https://www.npmjs.org/package/expect-element 8 | 9 | [expect-element](https://github.com/mjackson/expect-element) is an extension for [expect](https://github.com/mjackson/expect) that lets you write better assertions for DOM nodes. 10 | 11 | ## Installation 12 | 13 | Using [npm](https://www.npmjs.org/): 14 | 15 | $ npm install --save expect expect-element 16 | 17 | Then, use as you would anything else: 18 | 19 | ```js 20 | // using ES6 modules 21 | import expect from 'expect' 22 | import expectElement from 'expect-element' 23 | expect.extend(expectElement) 24 | 25 | // using CommonJS modules 26 | var expect = require('expect') 27 | var expectElement = require('expect-element') 28 | expect.extend(expectElement) 29 | ``` 30 | 31 | The UMD build is also available on [unpkg](https://unpkg.com): 32 | 33 | ```html 34 | 35 | ``` 36 | 37 | You can find the library on `window.expectElement`. 38 | 39 | ## Assertions 40 | 41 | ### toHaveAttribute 42 | 43 | > `expect(element).toHaveAttribute(name, [value, [message]])` 44 | 45 | Asserts the given DOM `element` has an attribute with the given `name`. If `value` is given, asserts the value of the attribute as well. 46 | 47 | ```js 48 | expect(element).toHaveAttribute('id') 49 | expect(element).toHaveAttribute('id', 'an-id') 50 | ``` 51 | 52 | ### toNotHaveAttribute 53 | 54 | > `expect(object).toNotHaveAttribute(name, [value, [message]])` 55 | 56 | Asserts the given DOM `element` does not have an attribute with the given `name`. If `value` is given, asserts the value of the attribute as well. 57 | 58 | ```js 59 | expect(element).toNotHaveAttribute('id') 60 | expect(element).toNotHaveAttribute('id', 'an-id') 61 | ``` 62 | 63 | ### toHaveAttributes 64 | 65 | > `expect(element).toHaveAttribute(attributes, [message])` 66 | 67 | Asserts the given DOM `element` has attributes with the names and values in `attributes`. 68 | 69 | ```js 70 | expect(element).toHaveAttributes({ 71 | id: 'an-id', 72 | 'class': 'a-class' 73 | }) 74 | ``` 75 | 76 | ### toNotHaveAttributes 77 | 78 | > `expect(element).toNotHaveAttribute(attributes, [message])` 79 | 80 | Asserts the given DOM `element` does not have attributes with the names and values in `attributes`. 81 | 82 | ```js 83 | expect(element).toNotHaveAttributes({ 84 | id: 'an-id', 85 | 'class': 'a-class' 86 | }) 87 | ``` 88 | 89 | ### toHaveText 90 | 91 | > `expect(element).toHaveText(text, [message])` 92 | 93 | Asserts the `textContent` of the given DOM `element` is `text`. 94 | 95 | ```js 96 | expect(element).toHaveText('hello world') 97 | ``` 98 | 99 | ### toNotHaveText 100 | 101 | > `expect(element).toNotHaveText(text, [message])` 102 | 103 | Asserts the `textContent` of the given DOM `element` is not `text`. 104 | 105 | ```js 106 | expect(element).toNotHaveText('hello world') 107 | ``` 108 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack') 2 | const projectName = require('./package').name 3 | 4 | module.exports = (config) => { 5 | const customLaunchers = { 6 | BS_Chrome: { 7 | base: 'BrowserStack', 8 | os: 'Windows', 9 | os_version: '10', 10 | browser: 'chrome', 11 | browser_version: '47.0' 12 | }, 13 | BS_Firefox: { 14 | base: 'BrowserStack', 15 | os: 'Windows', 16 | os_version: '10', 17 | browser: 'firefox', 18 | browser_version: '43.0' 19 | }, 20 | BS_Safari: { 21 | base: 'BrowserStack', 22 | os: 'OS X', 23 | os_version: 'El Capitan', 24 | browser: 'safari', 25 | browser_version: '9.0' 26 | }, 27 | BS_MobileSafari9: { 28 | base: 'BrowserStack', 29 | os: 'ios', 30 | os_version: '9.1', 31 | browser: 'iphone', 32 | real_mobile: false 33 | }, 34 | BS_InternetExplorer10: { 35 | base: 'BrowserStack', 36 | os: 'Windows', 37 | os_version: '8', 38 | browser: 'ie', 39 | browser_version: '10.0' 40 | }, 41 | BS_InternetExplorer11: { 42 | base: 'BrowserStack', 43 | os: 'Windows', 44 | os_version: '10', 45 | browser: 'ie', 46 | browser_version: '11.0' 47 | } 48 | } 49 | 50 | config.set({ 51 | customLaunchers: customLaunchers, 52 | 53 | browsers: [ 'Chrome' ], 54 | frameworks: [ 'mocha' ], 55 | reporters: [ 'mocha' ], 56 | 57 | files: [ 58 | 'tests.webpack.js' 59 | ], 60 | 61 | preprocessors: { 62 | 'tests.webpack.js': [ 'webpack', 'sourcemap' ] 63 | }, 64 | 65 | webpack: { 66 | devtool: 'inline-source-map', 67 | module: { 68 | loaders: [ 69 | { test: /\.js$/, exclude: /node_modules/, loader: 'babel' } 70 | ] 71 | }, 72 | plugins: [ 73 | new webpack.DefinePlugin({ 74 | 'process.env.NODE_ENV': JSON.stringify('test') 75 | }) 76 | ] 77 | }, 78 | 79 | webpackServer: { 80 | noInfo: true 81 | } 82 | }) 83 | 84 | if (process.env.USE_CLOUD) { 85 | config.browsers = Object.keys(customLaunchers) 86 | config.reporters = [ 'dots' ] 87 | config.concurrency = 2 88 | 89 | config.browserDisconnectTimeout = 10000 90 | config.browserDisconnectTolerance = 3 91 | 92 | if (process.env.TRAVIS) { 93 | config.browserStack = { 94 | project: projectName, 95 | build: process.env.TRAVIS_BUILD_NUMBER, 96 | name: process.env.TRAVIS_JOB_NUMBER 97 | } 98 | 99 | config.singleRun = true 100 | } else { 101 | config.browserStack = { 102 | project: projectName 103 | } 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /modules/TestUtils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns true if the given object is a DOM node. 3 | */ 4 | export const isDOMNode = (object) => 5 | object && typeof object.nodeType === 'number' 6 | -------------------------------------------------------------------------------- /modules/__tests__/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "mocha": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /modules/__tests__/toHaveAttribute-test.js: -------------------------------------------------------------------------------- 1 | import expect from 'expect' 2 | import expectElement from '../index' 3 | 4 | describe('toHaveAttribute', () => { 5 | before(() => { 6 | expect.extend(expectElement) 7 | }) 8 | 9 | let node 10 | beforeEach(() => { 11 | node = document.createElement('div') 12 | node.setAttribute('id', 'the-id') 13 | }) 14 | 15 | it('throws when the actual value is not a DOM node', () => { 16 | expect(() => { 17 | expect('string').toHaveAttribute('id') 18 | }).toThrow('must be a DOM node') 19 | }) 20 | 21 | it('does not throw when an element has a given attribute', () => { 22 | expect(() => { 23 | expect(node).toHaveAttribute('id') 24 | }).toNotThrow() 25 | }) 26 | 27 | it('does not throw when an element has a given attribute with a given value', () => { 28 | expect(() => { 29 | expect(node).toHaveAttribute('id', 'the-id') 30 | }).toNotThrow() 31 | }) 32 | 33 | it('throws when an element does not have a given attribute', () => { 34 | expect(() => { 35 | expect(node).toHaveAttribute('class') 36 | }).toThrow("to have a 'class' attribute") 37 | }) 38 | 39 | it('throws when an element does not have a given attribute with a given value', () => { 40 | expect(() => { 41 | expect(node).toHaveAttribute('id', 'not-the-id') 42 | }).toThrow("to have a 'id' attribute of 'not-the-id'") 43 | }) 44 | }) 45 | -------------------------------------------------------------------------------- /modules/__tests__/toHaveAttributes-test.js: -------------------------------------------------------------------------------- 1 | import expect from 'expect' 2 | import expectDOM from '../index' 3 | 4 | describe('toHaveAttributes', () => { 5 | before(() => { 6 | expect.extend(expectDOM) 7 | }) 8 | 9 | let node 10 | beforeEach(() => { 11 | node = document.createElement('div') 12 | node.setAttribute('id', 'the-id') 13 | node.setAttribute('class', 'the-class') 14 | }) 15 | 16 | it('throws when the actual value is not a DOM node', () => { 17 | expect(() => { 18 | expect('string').toHaveAttributes({}) 19 | }).toThrow('must be a DOM node') 20 | }) 21 | 22 | it('does not throw when an element has the given attributes', () => { 23 | expect(() => { 24 | expect(node).toHaveAttributes({ 25 | id: 'the-id', 26 | class: 'the-class' 27 | }) 28 | }).toNotThrow() 29 | }) 30 | 31 | it('throws when an element does not have the given attributes', () => { 32 | expect(() => { 33 | expect(node).toHaveAttributes({ 34 | id: 'not-the-id', 35 | class: 'not-the-class' 36 | }) 37 | }).toThrow() 38 | }) 39 | }) 40 | -------------------------------------------------------------------------------- /modules/__tests__/toHaveText-test.js: -------------------------------------------------------------------------------- 1 | import expect from 'expect' 2 | import expectDOM from '../index' 3 | 4 | describe('toHaveText', () => { 5 | before(() => { 6 | expect.extend(expectDOM) 7 | }) 8 | 9 | let node 10 | beforeEach(() => { 11 | node = document.createElement('div') 12 | node.appendChild( 13 | document.createTextNode('hello world') 14 | ) 15 | }) 16 | 17 | it('throws when the actual value is not a DOM node', () => { 18 | expect(() => { 19 | expect('string').toHaveText('') 20 | }).toThrow('must be a DOM node') 21 | }) 22 | 23 | it('does not throw when an element has the given text', () => { 24 | expect(() => { 25 | expect(node).toHaveText('hello world') 26 | }).toNotThrow() 27 | }) 28 | 29 | it('throws when an element does not have the given text', () => { 30 | expect(() => { 31 | expect(node).toHaveText('goodbye world') 32 | }).toThrow("to have 'goodbye world' text") 33 | }) 34 | }) 35 | -------------------------------------------------------------------------------- /modules/__tests__/toNotHaveAttribute-test.js: -------------------------------------------------------------------------------- 1 | import expect from 'expect' 2 | import expectDOM from '../index' 3 | 4 | describe('toNotHaveAttribute', () => { 5 | before(() => { 6 | expect.extend(expectDOM) 7 | }) 8 | 9 | let node 10 | beforeEach(() => { 11 | node = document.createElement('div') 12 | node.setAttribute('id', 'the-id') 13 | }) 14 | 15 | it('throws when the actual value is not a DOM node', () => { 16 | expect(() => { 17 | expect('string').toHaveAttribute('id') 18 | }).toThrow('must be a DOM node') 19 | }) 20 | 21 | it('throws when an element has a given attribute', () => { 22 | expect(() => { 23 | expect(node).toNotHaveAttribute('id') 24 | }).toThrow("to not have a 'id' attribute") 25 | }) 26 | 27 | it('throws when an element has a given attribute with a given value', () => { 28 | expect(() => { 29 | expect(node).toNotHaveAttribute('id', 'the-id') 30 | }).toThrow("to not have a 'id' attribute of 'the-id'") 31 | }) 32 | 33 | it('does not throw when an element does not have a given attribute', () => { 34 | expect(() => { 35 | expect(node).toNotHaveAttribute('class') 36 | }).toNotThrow() 37 | }) 38 | 39 | it('does not throw when an element does not have a given attribute with a given value', () => { 40 | expect(() => { 41 | expect(node).toNotHaveAttribute('id', 'not-the-id') 42 | }).toNotThrow() 43 | }) 44 | }) 45 | -------------------------------------------------------------------------------- /modules/__tests__/toNotHaveAttributes-test.js: -------------------------------------------------------------------------------- 1 | import expect from 'expect' 2 | import expectDOM from '../index' 3 | 4 | describe('toNotHaveAttributes', () => { 5 | before(() => { 6 | expect.extend(expectDOM) 7 | }) 8 | 9 | let node 10 | beforeEach(() => { 11 | node = document.createElement('div') 12 | node.setAttribute('id', 'the-id') 13 | node.setAttribute('class', 'the-class') 14 | }) 15 | 16 | it('throws when the actual value is not a DOM node', () => { 17 | expect(() => { 18 | expect('string').toNotHaveAttributes({}) 19 | }).toThrow('must be a DOM node') 20 | }) 21 | 22 | it('throws when an element has the given attributes', () => { 23 | expect(() => { 24 | expect(node).toNotHaveAttributes({ 25 | id: 'the-id', 26 | class: 'the-class' 27 | }) 28 | }).toThrow("to not have a 'id' attribute") 29 | }) 30 | 31 | it('does not throw when an element does not have the given attributes', () => { 32 | expect(() => { 33 | expect(node).toNotHaveAttributes({ 34 | id: 'not-the-id', 35 | class: 'not-the-class' 36 | }) 37 | }).toNotThrow() 38 | }) 39 | }) 40 | -------------------------------------------------------------------------------- /modules/__tests__/toNotHaveText-test.js: -------------------------------------------------------------------------------- 1 | import expect from 'expect' 2 | import expectDOM from '../index' 3 | 4 | describe('toNotHaveText', () => { 5 | before(() => { 6 | expect.extend(expectDOM) 7 | }) 8 | 9 | let node 10 | beforeEach(() => { 11 | node = document.createElement('div') 12 | node.appendChild( 13 | document.createTextNode('hello world') 14 | ) 15 | }) 16 | 17 | it('throws when the actual value is not a DOM node', () => { 18 | expect(() => { 19 | expect('string').toNotHaveText('') 20 | }).toThrow('must be a DOM node') 21 | }) 22 | 23 | it('throws when an element has the given text', () => { 24 | expect(() => { 25 | expect(node).toNotHaveText('hello world') 26 | }).toThrow("to not have 'hello world' text") 27 | }) 28 | 29 | it('does not throw when an element does not have the given text', () => { 30 | expect(() => { 31 | expect(node).toNotHaveText('goodbye world') 32 | }).toNotThrow() 33 | }) 34 | }) 35 | -------------------------------------------------------------------------------- /modules/index.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'expect' 2 | import { isDOMNode } from './TestUtils' 3 | 4 | export function toHaveAttribute(name, value, message) { 5 | assert( 6 | isDOMNode(this.actual), 7 | 'The "actual" argument in expect(actual).toHaveAttribute() must be a DOM node, %s was given', 8 | this.actual 9 | ) 10 | 11 | if (value == null) { 12 | assert( 13 | this.actual.getAttribute(name), 14 | (message || 'Expected %s to have a %s attribute, but it did not'), 15 | this.actual, 16 | name 17 | ) 18 | } else { 19 | assert( 20 | this.actual.getAttribute(name) === value, 21 | (message || 'Expected %s to have a %s attribute of %s, but it was %s'), 22 | this.actual, 23 | name, 24 | value, 25 | this.actual.getAttribute(name) 26 | ) 27 | } 28 | } 29 | 30 | export function toNotHaveAttribute(name, value, message) { 31 | assert( 32 | isDOMNode(this.actual), 33 | 'The "actual" argument in expect(actual).toNotHaveAttribute() must be a DOM node, %s was given', 34 | this.actual 35 | ) 36 | 37 | if (value == null) { 38 | assert( 39 | this.actual.getAttribute(name) == null, 40 | (message || 'Expected %s to not have a %s attribute, but it did'), 41 | this.actual, 42 | name 43 | ) 44 | } else { 45 | assert( 46 | this.actual.getAttribute(name) !== value, 47 | (message || 'Expected %s to not have a %s attribute of %s'), 48 | this.actual, 49 | name, 50 | value 51 | ) 52 | } 53 | } 54 | 55 | export function toHaveAttributes(attributes, message) { 56 | assert( 57 | isDOMNode(this.actual), 58 | 'The "actual" argument in expect(actual).toHaveAttributes() must be a DOM node, %s was given', 59 | this.actual 60 | ) 61 | 62 | for (const property in attributes) 63 | if (attributes.hasOwnProperty(property)) 64 | toHaveAttribute.call(this, property, attributes[property], message) 65 | } 66 | 67 | export function toNotHaveAttributes(attributes, message) { 68 | assert( 69 | isDOMNode(this.actual), 70 | 'The "actual" argument in expect(actual).toNotHaveAttributes() must be a DOM node, %s was given', 71 | this.actual 72 | ) 73 | 74 | for (const property in attributes) 75 | if (attributes.hasOwnProperty(property)) 76 | toNotHaveAttribute.call(this, property, attributes[property], message) 77 | } 78 | 79 | export function toHaveText(text, message) { 80 | assert( 81 | isDOMNode(this.actual), 82 | 'The "actual" argument in expect(actual).toHaveText() must be a DOM node, %s was given', 83 | this.actual 84 | ) 85 | 86 | assert( 87 | this.actual.textContent === text, 88 | (message || 'Expected %s to have %s text, but had %s instead'), 89 | this.actual, 90 | text, 91 | this.actual.textContent 92 | ) 93 | } 94 | 95 | export function toNotHaveText(text, message) { 96 | assert( 97 | isDOMNode(this.actual), 98 | 'The "actual" argument in expect(actual).toHaveText() must be a DOM node, %s was given', 99 | this.actual 100 | ) 101 | 102 | assert( 103 | this.actual.textContent !== text, 104 | (message || 'Expected %s to not have %s text'), 105 | this.actual, 106 | text 107 | ) 108 | } 109 | 110 | export default { 111 | toHaveAttribute, 112 | toHaveAttributes, 113 | toNotHaveAttribute, 114 | toNotHaveAttributes, 115 | toHaveText, 116 | toNotHaveText 117 | } 118 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "expect-element", 3 | "version": "1.1.1", 4 | "description": "Write better assertions for DOM nodes", 5 | "repository": "mjackson/expect-element", 6 | "author": "Michael Jackson", 7 | "license": "MIT", 8 | "main": "lib", 9 | "files": [ 10 | "lib", 11 | "umd" 12 | ], 13 | "scripts": { 14 | "build": "node ./scripts/build.js", 15 | "build-cjs": "babel ./modules -d lib --ignore '__tests__'", 16 | "build-umd": "webpack modules/index.js umd/expect-element.js", 17 | "build-min": "webpack -p modules/index.js umd/expect-element.min.js", 18 | "lint": "eslint modules", 19 | "test": "npm run lint && karma start", 20 | "release": "node ./scripts/release.js", 21 | "prepublish": "npm run build" 22 | }, 23 | "peerDependencies": { 24 | "expect": ">= 1.15.1" 25 | }, 26 | "devDependencies": { 27 | "babel-cli": "^6.6.5", 28 | "babel-eslint": "^6.0.0", 29 | "babel-loader": "^6.2.4", 30 | "babel-preset-es2015": "^6.6.0", 31 | "eslint": "^3.2.2", 32 | "eslint-plugin-import": "^1.12.0", 33 | "expect": "^1.20.2", 34 | "gzip-size": "^3.0.0", 35 | "karma": "^1.3.0", 36 | "karma-browserstack-launcher": "^1.0.0", 37 | "karma-chrome-launcher": "^1.0.1", 38 | "karma-mocha": "^1.0.1", 39 | "karma-mocha-reporter": "^2.0.3", 40 | "karma-sourcemap-loader": "^0.3.5", 41 | "karma-webpack": "^1.7.0", 42 | "mocha": "^3.0.2", 43 | "pretty-bytes": "^3.0.1", 44 | "readline-sync": "^1.4.1", 45 | "webpack": "^1.4.13" 46 | }, 47 | "keywords": [ 48 | "expect", 49 | "assert", 50 | "test", 51 | "spec", 52 | "dom" 53 | ] 54 | } 55 | -------------------------------------------------------------------------------- /scripts/build.js: -------------------------------------------------------------------------------- 1 | const readFileSync = require('fs').readFileSync 2 | const execSync = require('child_process').execSync 3 | const prettyBytes = require('pretty-bytes') 4 | const gzipSize = require('gzip-size') 5 | 6 | const exec = (command) => 7 | execSync(command, { stdio: 'inherit' }) 8 | 9 | exec('npm run build-cjs') 10 | exec('npm run build-umd') 11 | exec('npm run build-min') 12 | 13 | console.log( 14 | '\ngzipped, the UMD build is ' + prettyBytes( 15 | gzipSize.sync(readFileSync('umd/expect-element.min.js')) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /scripts/release.js: -------------------------------------------------------------------------------- 1 | const resolvePath = require('path').resolve 2 | const readFileSync = require('fs').readFileSync 3 | const execSync = require('child_process').execSync 4 | const prompt = require('readline-sync').question 5 | 6 | const exec = (command) => 7 | execSync(command, { stdio: 'inherit' }) 8 | 9 | const getPackageVersion = () => 10 | JSON.parse(readFileSync(resolvePath(__dirname, '../package.json'))).version 11 | 12 | if (process.cwd() !== resolvePath(__dirname, '..')) { 13 | console.error('The release script must be run from the repo root') 14 | process.exit(1) 15 | } 16 | 17 | // Get the next version, which may be specified as a semver 18 | // version number or anything `npm version` recognizes. This 19 | // is a "pre-release" if nextVersion is premajor, preminor, 20 | // prepatch, or prerelease 21 | const nextVersion = prompt(`Next version (current version is ${getPackageVersion()})? `) 22 | const isPrerelease = nextVersion.substring(0, 3) === 'pre' 23 | 24 | // 1) Make sure the tests pass 25 | exec('npm test -- --single-run') 26 | 27 | // 2) Increment the package version in package.json 28 | // 3) Create a new commit 29 | // 4) Create a v* tag that points to that commit 30 | exec(`npm version ${nextVersion} -m "Version %s"`) 31 | 32 | // 5) Push to GitHub master. Do this before we publish in 33 | // case anyone has pushed to GitHub since we last pulled 34 | exec('git push origin master') 35 | 36 | // 6) Publish to npm. Use the "next" tag for pre-releases, 37 | // "latest" for all others 38 | exec(`npm publish --tag ${isPrerelease ? 'next' : 'latest'}`) 39 | 40 | // 7) Push the v* tag to GitHub 41 | exec(`git push -f origin v${getPackageVersion()}`) 42 | 43 | // 8) Push the "latest" tag to GitHub 44 | if (!isPrerelease) { 45 | exec('git tag -f latest') 46 | exec('git push -f origin latest') 47 | } 48 | -------------------------------------------------------------------------------- /tests.webpack.js: -------------------------------------------------------------------------------- 1 | var context = require.context('./modules', true, /-test\.js$/) 2 | context.keys().forEach(context) 3 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | output: { 4 | library: 'expectElement', 5 | libraryTarget: 'umd' 6 | }, 7 | 8 | module: { 9 | loaders: [ 10 | { test: /\.js$/, exclude: /node_modules/, loader: 'babel' } 11 | ] 12 | } 13 | 14 | } 15 | --------------------------------------------------------------------------------