Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: enzymejs/enzyme
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: enzyme@3.4.1
Choose a base ref
...
head repository: enzymejs/enzyme
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: enzyme@3.4.2
Choose a head ref
  • 9 commits
  • 31 files changed
  • 4 contributors

Commits on Jun 17, 2018

  1. [Fix] selectors: fix descendant selector.

    (Selectors like '.foo div' should not match on `<div className="foo" />`)
    ReactiveRaven authored and ljharb committed Jun 17, 2018

    Partially verified

    This commit is signed with the committer’s verified signature.
    ljharb’s contribution has been verified via GPG key.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    40a2ce3 View commit details

Commits on Aug 9, 2018

  1. [Tests] remove mistakenly committed .only

    koba04 authored and ljharb committed Aug 9, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    18616fd View commit details
  2. [Fix] shallow: call cDU when an instance calls setState

    stub instance.setState when the component is mounting
    
    Fixes #1452.
    koba04 authored and ljharb committed Aug 9, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    a50570d View commit details

Commits on Aug 13, 2018

  1. [Tests] tweak descriptions

    ljharb committed Aug 13, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    f31c525 View commit details

Commits on Aug 15, 2018

  1. [Dev Deps] update eslint, eslint-config-airbnb, `eslint-plugin-im…

    …port`, `eslint-plugin-react`
    ljharb committed Aug 15, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    9ea7ee9 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    65e14d6 View commit details
  3. Documenting Enzyme configuration with Karma

    Jonathan Felchlin committed Aug 15, 2018
    Copy the full SHA
    1b0c212 View commit details
  4. [Tests] add createRef tests

    Closes #1704
    ljharb committed Aug 15, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    d8a45b9 View commit details

Commits on Aug 16, 2018

  1. [enzyme] v3.4.2

    ljharb committed Aug 16, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    8eabf3b View commit details
53 changes: 49 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,49 @@
_book/
build/
node_modules/
**/node_modules/
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# Jetbrains IDEs
.idea

/build
_book

# Only apps should have lockfiles
npm-shrinkwrap.json
package-lock.json
yarn.lock

.DS_Store
._.DS_Store

packages/*/build/

# Temporarily copied
packages/*/LICENSE.md
packages/enzyme/README.md
packages/enzyme-adapter-react-*/README.md
packages/enzyme-adapter-utils*/README.md
29 changes: 27 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
"mocha": true
},
"rules": {
"react/jsx-one-expression-per-line": 0, // TODO: re-enable once fixed
"id-length": 0,
"new-cap": [2, { "capIsNewExceptions": ["AND"] }],
"react/jsx-pascal-case": [2, { "allowAllCaps": true }],
@@ -28,5 +27,31 @@
"_stringText",
],
}],
}
},
"overrides": [
{
"files": [
"*.md",
//"**/*.md",
],
"plugins": [
"markdown"
],
"rules": {
"class-methods-use-this": 0,
"import/no-unresolved": 0,
"import/no-extraneous-dependencies": 0,
"import/extensions": 0,
"max-len": 0,
"no-unused-vars": 0,
"no-console": 0,
"no-undef": 0,
"react/react-in-jsx-scope": 0,
"react/jsx-filename-extension": 0,
"react/jsx-no-undef": 0,
"react/no-multi-comp": 0,
"react/jsx-one-expression-per-line": 0,
},
}
],
}
21 changes: 0 additions & 21 deletions .eslintrc-markdown

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 3.4.2

### Fixes
- @koba04: `shallow`: call cDU when an instance calls setState ([#1742](https://github.com/airbnb/enzyme/pull/1742))
- @ReactiveRaven: `selectors`: fix descendant selector ([#1680](https://github.com/airbnb/enzyme/pull/1680))

## 3.4.1

### Fixes
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ testing your React components, you can consider using:

[Using Enzyme with SystemJS](/docs/guides/systemjs.md)

[Using Enzyme with WebPack](/docs/guides/webpack.md)
[Using Enzyme with Webpack](/docs/guides/webpack.md)

[Using Enzyme with JSDOM](/docs/guides/jsdom.md)

2 changes: 1 addition & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
* [Guides](/docs/guides.md)
* [Migration from 2.x to 3.x](/docs/guides/migration-from-2-to-3.md)
* [Browserify](/docs/guides/browserify.md)
* [WebPack](/docs/guides/webpack.md)
* [Webpack](/docs/guides/webpack.md)
* [JSDOM](/docs/guides/jsdom.md)
* [Jest](/docs/guides/jest.md)
* [Karma](/docs/guides/karma.md)
2 changes: 1 addition & 1 deletion docs/guides.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# enzyme Guides

- [*Using enzyme with Browserify*](guides/browserify.md)
- [*Using enzyme with WebPack*](guides/webpack.md)
- [*Using enzyme with Webpack*](guides/webpack.md)
- [*Using enzyme with JSDOM*](guides/jsdom.md)
- [*Using enzyme with Jest*](guides/jest.md)
- [*Using enzyme with Karma*](guides/karma.md)
88 changes: 47 additions & 41 deletions docs/guides/karma.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,61 @@
# Using enzyme with Karma

Karma is a popular test runner that can run tests in browser environments. enzyme is compatible with
Karma, but often requires a little bit of configuration.
Karma is a popular test runner that can run tests in multiple browser environments. Depending on your Karma setup, you may have a number of options for configuring Enzyme.

This configuration largely depends on which plugins you are using to bundle your JavaScript code. In
the case of Browserify or Webpack, see the below documentation in order to get these up and running.
## Basic Enzyme setup with Karma

### Configure Enzyme

## enzyme + Karma + Webpack
Create an Enzyme setup file. This file will configure Enzyme with the appropiate React adapter. It can also be used to initialize any that you'd like available for all tests. To avoid having to import this file and Enzyme, you can re-export all Enzyme exports from this file and just import it.

See the [webpack guide](webpack.md).
```js
/* test/enzyme.js */
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import jasmineEnzyme from 'jasmine-enzyme';

// Configure Enzyme for the appropriate React adapter
Enzyme.configure({ adapter: new Adapter() });

// Initialize global helpers
beforeEach(() => {
jasmineEnzyme();
});

// Re-export all enzyme exports
export * from 'enzyme';
```

### Import Enzyme from the Enzyme setup file

Anywhere you want to use Enzyme, import the Enzyme setup file just as you would Enzyme itself.

```js
/* karma.conf.js */
module.exports = function karmaConfig(config) {
config.set({
// ...
webpack: { // kind of a copy of your webpack config
devtool: 'inline-source-map', // just do inline source maps instead of the default
module: {
loaders: [{
test: /\.js$/,
exclude: /\/node_modules\//,
loader: 'babel',
query: {
presets: ['airbnb'],
},
}],
},
},
// ...
});
};
/* some_test.js */
// Import anything you would normally import `from 'enzyme'` from the Enzyme setup file
import { shallow } from './test/enzyme';

// ...
```

## enzyme + Karma + Browserify

See the [browserify guide](browserify.md).
## Alternative karma-webpack setup

If you're using Karma and Webpack using [karma-webpack's alternative setup](https://github.com/webpack-contrib/karma-webpack#alternative-usage), you can configure enzyme in your test entry file and import Enzyme directly in individual tests.

```js
/* karma.conf.js */
module.exports = function karmaConfig(config) {
config.set({
// ...
browserify: {
debug: true,
transform: [
['babelify', { presets: ['airbnb'] }],
],
},
// ...
});
};
/* test/index_test.js */
import './enzyme';

const testsContext = require.context('.', true, /_test$/);

testsContext.keys().forEach(testsContext);
```

```js
/* some_test.js */
// If Enzyme is configured in the test entry file, Enzyme can be imported directly
import { shallow } from 'enzyme';

// ...
```
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -12,8 +12,8 @@
"postversion": "git push && git push --tags && npm run clean && npm run docs:publish",
"version": "lerna run build",
"clean": "lerna run clean",
"prelint": "npm run docs:lint",
"lint": "lerna exec --parallel 'npm run lint -- --quiet'",
"postlint": "npm run docs:lint",
"check": "lerna run lint && npm run test:all",
"prebuild": "npm run clean",
"build": "lerna run build",
@@ -38,7 +38,7 @@
"react:16": "npm run env -- 16",
"env": "babel-node ./env.js",
"docs:clean": "rimraf _book",
"docs:lint": "eslint --ext md --config .eslintrc-markdown --ignore-path .eslintignore .",
"docs:lint": "eslint --ext md --ignore-path .eslintignore .",
"docs:prepare": "gitbook install",
"docs:build": "npm run docs:prepare && gitbook build",
"docs:watch": "npm run docs:prepare && gitbook serve",
@@ -76,12 +76,12 @@
"babel-register": "^6.26.0",
"chai": "^4.1.2",
"coveralls": "^2.13.3",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-markdown": "^1.0.0-beta.7",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-react": "^7.11.1",
"gitbook-cli": "^1.0.1",
"gitbook-plugin-anchors": "^0.7.1",
"gitbook-plugin-codeblock-disable-glossary": "0.0.1",
8 changes: 4 additions & 4 deletions packages/enzyme-adapter-react-13/package.json
Original file line number Diff line number Diff line change
@@ -48,11 +48,11 @@
"babel-plugin-transform-replace-object-assign": "^1.0.0",
"babel-preset-airbnb": "^2.5.3",
"enzyme": "^3.0.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-react": "^7.11.1",
"in-publish": "^2.0.0",
"rimraf": "^2.6.2",
"safe-publish-latest": "^1.1.2"
8 changes: 4 additions & 4 deletions packages/enzyme-adapter-react-14/package.json
Original file line number Diff line number Diff line change
@@ -51,11 +51,11 @@
"babel-plugin-transform-replace-object-assign": "^1.0.0",
"babel-preset-airbnb": "^2.5.3",
"enzyme": "^3.0.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-react": "^7.11.1",
"in-publish": "^2.0.0",
"rimraf": "^2.6.2",
"safe-publish-latest": "^1.1.2"
8 changes: 4 additions & 4 deletions packages/enzyme-adapter-react-15.4/package.json
Original file line number Diff line number Diff line change
@@ -52,11 +52,11 @@
"babel-plugin-transform-replace-object-assign": "^1.0.0",
"babel-preset-airbnb": "^2.5.3",
"enzyme": "^3.0.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-react": "^7.11.1",
"in-publish": "^2.0.0",
"rimraf": "^2.6.2",
"safe-publish-latest": "^1.1.2"
8 changes: 4 additions & 4 deletions packages/enzyme-adapter-react-15/package.json
Original file line number Diff line number Diff line change
@@ -51,11 +51,11 @@
"babel-plugin-transform-replace-object-assign": "^1.0.0",
"babel-preset-airbnb": "^2.5.3",
"enzyme": "^3.0.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-react": "^7.11.1",
"in-publish": "^2.0.0",
"rimraf": "^2.6.2",
"safe-publish-latest": "^1.1.2"
8 changes: 4 additions & 4 deletions packages/enzyme-adapter-react-16.1/package.json
Original file line number Diff line number Diff line change
@@ -51,11 +51,11 @@
"babel-plugin-transform-replace-object-assign": "^1.0.0",
"babel-preset-airbnb": "^2.5.3",
"enzyme": "^3.0.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-react": "^7.11.1",
"in-publish": "^2.0.0",
"rimraf": "^2.6.2",
"safe-publish-latest": "^1.1.2"
8 changes: 4 additions & 4 deletions packages/enzyme-adapter-react-16.2/package.json
Original file line number Diff line number Diff line change
@@ -52,11 +52,11 @@
"babel-plugin-transform-replace-object-assign": "^1.0.0",
"babel-preset-airbnb": "^2.5.3",
"enzyme": "^3.0.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-react": "^7.11.1",
"in-publish": "^2.0.0",
"rimraf": "^2.6.2",
"safe-publish-latest": "^1.1.2"
Loading