Skip to content

Commit

Permalink
Monorepo! Publish framework specific packages (#42)
Browse files Browse the repository at this point in the history
* Add Lerna

* v1.3.0-beta

* fix publish please use

* v1.3.0-beta2

* start migration

* Almost there!

* This might be it!

* v2.0.0-rc1

* add readmez

* notes

* Update README.md

* Update README.md

* Update

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* package updates

* prepublish build

* v2.0.0-rc2

* v2.0.0-rc3

* fix lint and flow

* v2.0.0-rc4

* circleci fixes

* circleci fixes

* fix circleci yml

* circleci: use dep field

* fix jasmine call

* add jasmine to devDeps
  • Loading branch information
blainekasten authored Oct 13, 2016
1 parent 43fadb1 commit c7ff18b
Show file tree
Hide file tree
Showing 104 changed files with 2,028 additions and 2,028 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules/**
**/lib/**
**/*.fixture.js
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.*/node_modules/fbjs.*

[include]
./packages/enzyme-matchers/src/index.js

[libs]

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules/
lib/
npm-debug.log
lerna-debug.log
.DS_Store
13 changes: 0 additions & 13 deletions .publishrc

This file was deleted.

12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2.0.0
=====
* **Changed project structure!**
* We are now using lerna to maintain 3 npm packages:
* `enzyme-matchers` (_simple functions to handle assertions_)
* `jasmine-enzyme` (_implementation of enzyme-matchers in jasmine_)
* `jest-enzyme` (_implementation of enzyme-matchers in jest)

* This is only breaking if you use Jest.
* If you do, simply change to use the `jest-enzyme` package and everything should work.


1.2.0
=====
* Fixed negated matchers output message to sound negated.
Expand Down
135 changes: 41 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,50 @@
# jasmine-enzyme
# enzyme-matchers

[![npm version](https://img.shields.io/npm/v/jasmine-enzyme.svg)](https://www.npmjs.com/package/jasmine-enzyme)
![License](https://img.shields.io/npm/l/chai-enzyme.svg)
[![Circle CI](https://circleci.com/gh/blainekasten/jasmine-enzyme/tree/master.svg?style=svg)](https://circleci.com/gh/blainekasten/jasmine-enzyme/tree/master)

[Jasmine](http://jasmine.github.io/) assertions for [enzyme](https://github.com/airbnb/enzyme/).

Large thanks to [`chai-enzyme`](https://github.com/producthunt/chai-enzyme). We have taken several thoughts from that library and ultimately hope to maintain feature parity.

## Table of Contents

1. [Installation](#installation)
1. [Setup](#setup)
1. [Jest](#jest)
1. [Jasmine](#vanilla-jasmine)
1. [Assertions](#assertions)
1. [toBeChecked()](#tobechecked)
1. [toBeDisabled()](#tobedisabled)
1. [toBeEmpty()](#tobeempty)
1. [toBePresent()](#tobepresent)
1. [toContainReact()](#tocontainreactreactinstanceobject)
1. [toHaveClassName()](#tohaveclassnameclassnamestring)
1. [toHaveHTML()](#tohavehtmlhtmlstring)
1. [toHaveProp()](#tohaveproppropkeystring-propvalueany)
1. [toHaveRef()](#tohaverefrefnamestring)
1. [toHaveState()](#tohavestatestatekeystring-statevalueany)
1. [toHaveStyle()](#tohavestylestylekeystring-stylevalueany)
1. [toHaveTagName()](#tohavetagnametagnamestring)
1. [toHaveText()](#tohavetexttextstring)
1. [toHaveValue()](#tohavevaluevalueany)
1. [toMatchSelector()](#tomatchselectorselectorstring)
1. [Development](#development)
1. [Contributing](#contributing)
1. [License](#license)

## Installation

`jasmine-enzyme` depends on:
[![Circle CI](https://circleci.com/gh/blainekasten/enzyme-matchers/tree/master.svg?style=svg)](https://circleci.com/gh/blainekasten/enzyme-matchers/tree/master)

An assertion library for [enzyme](https://github.com/airbnb/enzyme/).

```js
"peerDependencies": {
"jasmine": "1.x || 2.x",
"enzyme": "1.x || 2.x"
}
```

```
$ npm install jasmine-enzyme --save-dev
```

## Setup

### Jest
If you are using [jest](https://facebook.github.io/jest/), the simplest setup
is to use jest's `setupTestFrameworkScriptFile` config.

Make sure your `package.json` includes the following:
This library supports several testing frameworks including [Jest](https://github.com/facebook/jest) and [Jasmine](http://jasmine.github.io/).

```json
"jest": {
"setupTestFrameworkScriptFile": "node_modules/jasmine-enzyme/lib/jest.js"
},
```

If you are using a jest version lower than `15` you'll also need to tell it to unmock `react`, `enzyme`, and `jasmine-enzyme`.

```json
"jest": {
"setupTestFrameworkScriptFile": "node_modules/jasmine-enzyme/lib/jest.js",
"unmockedModulePathPatterns": [
"react",
"enzyme",
"jasmine-enzyme"
]
},
```
> _Want to add support for another testing framework? Check out our [contributing](#contributing) doc!_
### Vanilla Jasmine
If you are just using vanilla jasmine, you'll need to call
`jasmineEnzyme()` in any `before` method due to the way jasmine's plugin
system works.

```js
import jasmineEnzyme from 'jasmine-enzyme';
### Readme's for each package:

describe('test', () => {
beforeEach(() => {
jasmineEnzyme();
});

// tests
});
```
* [enzyme-matchers](/packages/enzyme-matchers/README.md)
* [jasmine-enzyme](/packages/jasmine-enzyme/README.md)
* [jest-enzyme](/packages/jest-enzyme/README.md)

## Assertions

> Note that not all assertions work with every rendering strategy.
> If you are wondering what rendering mechanism to use when, refer to
> [enzyme's documentation](https://github.com/airbnb/enzyme).
> Notes
> * The syntax for using these assertions may be different depending on your testing framework. For more information, visit the framework you are using's package README in `packages/`
> * Not all assertions work with every rendering strategy.
> If you are wondering what rendering mechanism to use when, refer to
> [enzyme's documentation](https://github.com/airbnb/enzyme).
* [toBeChecked()](#tobechecked)
* [toBeDisabled()](#tobedisabled)
* [toBeEmpty()](#tobeempty)
* [toBePresent()](#tobepresent)
* [toContainReact()](#tocontainreactreactinstanceobject)
* [toHaveClassName()](#tohaveclassnameclassnamestring)
* [toHaveHTML()](#tohavehtmlhtmlstring)
* [toHaveProp()](#tohaveproppropkeystring-propvalueany)
* [toHaveRef()](#tohaverefrefnamestring)
* [toHaveState()](#tohavestatestatekeystring-statevalueany)
* [toHaveStyle()](#tohavestylestylekeystring-stylevalueany)
* [toHaveTagName()](#tohavetagnametagnamestring)
* [toHaveText()](#tohavetexttextstring)
* [toHaveValue()](#tohavevaluevalueany)
* [toMatchSelector()](#tomatchselectorselectorstring)

_Other_

1. [Development](#development)
1. [Contributing](#contributing)
1. [License](#license)

#### `toBeChecked()`

Expand Down Expand Up @@ -515,8 +460,8 @@ expect(wrapper.find('span')).toMatchSelector('.bar');

```shell
$ git clone <this repo>
$ cd jasmine-enzyme
$ npm install
$ cd enzyme-matchers
$ lerna bootstrap
```

#### Tests
Expand All @@ -537,6 +482,8 @@ $ npm test

We want to make this assertion library as robust and complete as possible. If you think that there are missing features/assertions, please open a GitHub issue or even better - a PR.

This project uses [lerna](https://github.com/lerna/lerna)

Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org/) code of conduct.

## License
Expand Down
6 changes: 5 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ machine:

test:
pre:
- npm run lint
- lerna run lint

dependencies:
post:
- lerna bootstrap
4 changes: 4 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"lerna": "2.0.0-beta.30",
"version": "2.0.0-rc4"
}
42 changes: 17 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"name": "jasmine-enzyme",
"version": "1.2.0",
"description": "Jasmine assertions for enzyme",
"main": "lib/index.js",
"name": "enzyme-assertions",
"description": "Testing Helpers for Enzyme",
"author": "Blaine Kasten<[email protected]>",
"license": "MIT",
"scripts": {
"test": "jest",
"lint": "eslint ./src",
"build": "rimraf lib && babel src --out-dir lib --ignore tests",
"prior-to-publish": "npm run lint && npm test && npm run build",
"publish-please": "publish-please",
"prepublish": "publish-please guard"
"pretest": "node ./scripts/jest.js",
"test": "npm run test-matchers && npm run test-jasmine && npm run test-jest",
"test-matchers": "cd ./packages/enzyme-matchers && npm run jest",
"test-jasmine": "cd ./packages/jasmine-enzyme && npm run jest && npm run jasmine",
"test-jest": "cd ./packages/jest-enzyme && npm run jest",
"lint": "eslint ./packages"
},
"files": [
"src",
"lib"
],
"repository": {
"type": "git",
"url": "https://github.com/blainekasten/jasmine-enzyme.git"
"url": "git+https://github.com/blainekasten/enzyme-matchers.git"
},
"keywords": [
"javascript",
Expand All @@ -35,11 +35,6 @@
"jest",
"enzyme"
],
"author": "Blaine Kasten<[email protected]>",
"license": "MIT",
"peerDependencies": {
"enzyme": "1.x || 2.x"
},
"devDependencies": {
"babel-cli": "^6.5.1",
"babel-eslint": "^6.0.0",
Expand All @@ -52,22 +47,19 @@
"eslint": "^2.7.0",
"eslint-config-airbnb": "^6.2.0",
"eslint-plugin-react": "^4.3.0",
"jest-cli": "^12.0.0",
"publish-please": "^2.1.4",
"jest-cli": "^16.0.1",
"react": "^0.14.7",
"react-addons-test-utils": "^0.14.7",
"react-dom": "^0.14.7",
"readline-sync": "^1.4.1",
"rimraf": "^2.5.0"
"rimraf": "^2.5.0",
"lerna": "2.0.0-beta.30"
},
"jest": {
"testPathDirs": [
"<rootDir>/src"
],
"setupTestFrameworkScriptFile": "./src/jest.js",
"unmockedModulePathPatterns": [
"enzyme",
"react"
"<rootDir>/packages/jasmine-enzyme/src",
"<rootDir>/packages/jest-enzyme/src",
"<rootDir>/packages/enzyme-matchers/src"
],
"verbose": true
}
Expand Down
21 changes: 21 additions & 0 deletions packages/enzyme-matchers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# enzyme-matchers

[![npm version](https://img.shields.io/npm/v/enzyme-matchers.svg)](https://www.npmjs.com/package/enzyme-matchers)
![License](https://img.shields.io/npm/l/chai-enzyme.svg)
[![Circle CI](https://circleci.com/gh/blainekasten/enzyme-matchers/tree/master.svg?style=svg)](https://circleci.com/gh/blainekasten/enzyme-matchers/tree/master)

This package is primarily meant to be consumed by framework integrations within [this monorepo](https://github.com/blainekasten/enzyme-matchers). Though it can be used standalone. Look at the source if you want to see how it's used.

### Installation

We suggest using [yarn](https://github.com/yarnpkg/yarn) for installations.

```
yarn add enzyme-matchers --dev
```

But npm works too!

```
$ npm install enzyme-matchers --save-dev
```
36 changes: 36 additions & 0 deletions packages/enzyme-matchers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "enzyme-matchers",
"version": "2.0.0-rc4",
"description": "Testing Matchers for Enzyme",
"main": "lib/index.js",
"homepage": "https://github.com/blainekasten/enzyme-matchers/packages/enzyme-matchers#readme",
"author": "Blaine Kasten <[email protected]>",
"license": "MIT",
"scripts": {
"pretest": "node ../../scripts/jest.js",
"test": "jest",
"jest": "jest",
"lint": "eslint ./src",
"prepublish": "npm run build",
"build": "babel src --out-dir lib --ignore tests"
},
"repository": {
"type": "git",
"url": "git+https://github.com/blainekasten/enzyme-matchers.git"
},
"bugs": {
"url": "https://github.com/blainekasten/enzyme-matchers/issues"
},
"peerDependencies": {
"enzyme": "1.x || 2.x"
},
"dependencies": {
"deep-equal-ident": "^1.1.1"
},
"jest": {
"testPathDirs": [
"<rootDir>/src"
],
"verbose": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { shallow } = require('enzyme');
const React = require('react');
const toBeChecked = require('../toBeChecked');

function Fixture() {
return (
<div>
<input id="checked" defaultChecked />
<input id="not" defaultChecked={false} />
<input id="tertiary" defaultChecked checked={false} />
</div>
);
}

describe('toBeChecked', () => {
const wrapper = shallow(<Fixture />);
const truthyResults = toBeChecked(wrapper.find('#checked'));
const falsyResults = toBeChecked(wrapper.find('#not'));

it('returns the pass flag properly', () => {
expect(truthyResults.pass).toBeTruthy();
expect(falsyResults.pass).toBeFalsy();
});

it('returns the message with the proper pass/fail verbage', () => {
expect(truthyResults.message).not.toContain('not');
expect(falsyResults.message).toContain('not');
});
});

Loading

0 comments on commit c7ff18b

Please sign in to comment.