Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mochiya98 committed Mar 4, 2019
0 parents commit 7739411
Show file tree
Hide file tree
Showing 15 changed files with 6,277 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

# prettier
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
extends: [
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended"
],
plugins: ["prettier", "jest", "react", "typescript-sort-keys"],
parserOptions: {
sourceType: "module",
project: "./tsconfig.json"
},
rules: {
"prettier/prettier": "error",
"sort-keys": "error",
"typescript-sort-keys/interface": "error",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{ varsIgnorePattern: "React" }
]
},
settings: {
react: { version: "detect" }
}
};
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/coverage/
/dist/
node_modules/
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/coverage/
/src/
/test/
/_*
.editorconfig
.eslintrc.js
.travis.yml
jest.config.js
tsconfig.json
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cache: npm
dist: xenial
git:
depth: 1
language: node_js
node_js:
- stable
- lts/*
before_install:
- npm set progress false
after_success:
- cat ./coverage/lcov.info | npx coveralls
deploy:
email: yukimasafunaoka@gmail.com
provider: npm
skip_cleanup: true
on:
tags: true
api_key:
secure: X/tRwLcHvYzWJzA5qaKZG4QrGRw4WUYiScjgqHkmMPMMvClChQRJGY9FfNou2WlLNrk+H6V/5jA9p4c2MMNH8rx7kmcu2zTiMtegacfFIYIyMW1PGUQXKml0bul8WHsUJfHk7h39S06vPlaBwx2Y3zOjuB+zlFCr12k4xi/kcFFn2JqVSlwRaVCsXYQ3Dn0MR/yVqbVHf/RIs4QYpTe8NAzX5e17AcbmxOZDE8QMjNsQxhAiwxP4XjBiVwWjCUpYPdqxX3mw4e99sw++zACkgT9kkood3p22hx5wguAwlxfRNMEjB1IuGDkLgSDZLLDws0I9LT+BO4huYiKtqUtRP+LB6nL+bKmRn0ZiPv9Tbyj+08t4kVd6ufu9HhRipkhbGpp5a22gFfw6gduCDLk3TU6XzAXQjIn7P+TtQ1/B1BGizJzZWqwwHfrBRa80cF1lGMzGfHDMhMWUgDhTnywE8FBgj/8oORDK+IwV+xGBozVIg9fpYwuLV6VUReVH6xsSx2X7rUBoSKnbE26pfrtl3Jd9wfXdFp/fUb8ELooOs/Sh3oGYDdCN9NpDvnt5+HQPT3QT5ZwByoNaDapFu/LVrBrdwevgMhb+6bBYbB2jsWjj/F0LMO0vFgXqPuEMv6yWNNUh3zBMTkPmwAiYvTtV1Dj26lL7zhvjhP4JrNiauwc=
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Yukimasa Funaoka

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# react-test-renderer-tree-to-json

[![Build Status](https://img.shields.io/travis/mochiya98/react-test-renderer-tree-to-json.svg?branch=master&style=flat-square)](https://travis-ci.org/mochiya98/react-test-renderer-tree-to-json) [![Coverage Status](https://img.shields.io/coveralls/github/mochiya98/react-test-renderer-tree-to-json.svg?style=flat-square)](https://coveralls.io/github/mochiya98/react-test-renderer-tree-to-json?branch=master)
[![npm Version](https://img.shields.io/npm/v/react-test-renderer-tree-to-json.svg?style=flat-square)](https://www.npmjs.com/package/react-test-renderer-tree-to-json) [![License](https://img.shields.io/npm/l/react-test-renderer-tree-to-json.svg?style=flat-square)](https://www.npmjs.com/package/react-test-renderer-tree-to-json) [![Downloads](https://img.shields.io/npm/dm/react-test-renderer-tree-to-json.svg?style=flat-square)](https://npm-stat.com/charts.html?package=react-test-renderer-tree-to-json)

Convert [React Test Renderer](https://reactjs.org/docs/test-renderer.html) tree to a format compatible with [Jest snapshot testing](https://facebook.github.io/jest/docs/tutorial-react.html#snapshot-testing).
This is similar to [enzyme-to-json](https://github.com/adriantoine/enzyme-to-json).

# Install

```console
$ npm i -D react-test-renderer-tree-to-json
```

# Usage

Only for full rendering without key props.

```jsx
import React from "react";

import TestRenderer from "react-test-renderer";
import { treeToJSON } from "react-test-renderer-tree-to-json";

import { mount } from "enzyme";
import toJson from "enzyme-to-json";

const Hoge = () => <div />;

it("snapshot", () => {
const renderer = TestRenderer.create(<Hoge />);
const tree = renderer.toTree();
expect(treeToJSON(tree)).toMatchSnapshot();
// similar to
const wrapper = mount(<Hoge />);
expect(toJson(wrapper, { noKey: true })).toMatchSnapshot();
});
/*-----------------------
exports[`snapshot 1`] = `
<Hoge>
<div />
</Hoge>
`;
-----------------------*/
```
25 changes: 25 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
clearMocks: true,
collectCoverage: true,
collectCoverageFrom: [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.{test,spec}.{js,jsx,ts,tsx}",
"!**/__tests__/**",
"!**/node_modules/**"
],
coverageDirectory: "coverage",
coverageReporters: ["json", "text", "lcov"],
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100
}
},
testURL: "http://localhost/",
transform: {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": "ts-jest"
}
};

0 comments on commit 7739411

Please sign in to comment.