Browse Source

test: demo snapshot testing (#3916)

* Run snapshot testing against all demos

* Split demo tests

* ignore coverage folder

* Upgrade antd-demo-jest

* enable cache

* intergate with coveralls.io

* Add node test

* Set worker to 2

https://github.com/facebook/jest/issues/1742

* config coverage

* Set default supportServerRender to true
pull/3953/head
Wei Zhu 8 years ago
committed by Benjy Cui
parent
commit
d20572bdab
  1. 5
      .babelrc
  2. 1
      .gitignore
  3. 15
      .jest.node.json
  4. 3
      .travis.yml
  5. 2
      components/table/demo/grouping-columns.md
  6. 4
      components/transfer/demo/basic.md
  7. 1
      components/upload/index.tsx
  8. 35
      package.json
  9. 3
      tests/affix/demo.test.js
  10. 3
      tests/alert/demo.test.js
  11. 3
      tests/anchor/demo.test.js
  12. 3
      tests/auto-complete/demo.test.js
  13. 3
      tests/back-top/demo.test.js
  14. 3
      tests/badge/demo.test.js
  15. 3
      tests/breadcrumb/demo.test.js
  16. 0
      tests/button/__snapshots__/index.test.js.snap
  17. 3
      tests/button/demo.test.js
  18. 2
      tests/button/index.test.js
  19. 3
      tests/calendar/demo.test.js
  20. 3
      tests/card/demo.test.js
  21. 12
      tests/carousel/demo.test.js
  22. 3
      tests/checkbox/demo.test.js
  23. 3
      tests/collapse/demo.test.js
  24. 3
      tests/date-picker/demo.test.js
  25. 3
      tests/dropdown/demo.test.js
  26. 3
      tests/form/demo.test.js
  27. 3
      tests/grid/demo.test.js
  28. 2
      tests/icon/index.test.js
  29. 3
      tests/input-number/demo.test.js
  30. 3
      tests/input/demo.test.js
  31. 2
      tests/layout/index.test.js
  32. 3
      tests/locale-provider/demo.test.js
  33. 3
      tests/mention/demo.test.js
  34. 3
      tests/menu/demo.test.js
  35. 3
      tests/message/demo.test.js
  36. 3
      tests/modal/demo.test.js
  37. 3
      tests/notification/demo.test.js
  38. 3
      tests/pagination/demo.test.js
  39. 3
      tests/popconfirm/demo.test.js
  40. 3
      tests/popover/demo.test.js
  41. 2
      tests/popover/index.test.js
  42. 3
      tests/progress/demo.test.js
  43. 3
      tests/radio/demo.test.js
  44. 3
      tests/rate/demo.test.js
  45. 3
      tests/select/demo.test.js
  46. 16
      tests/shared/demoTest.js
  47. 3
      tests/slider/demo.test.js
  48. 3
      tests/spin/demo.test.js
  49. 3
      tests/steps/demo.test.js
  50. 3
      tests/switch/demo.test.js
  51. 3
      tests/table/demo.test.js
  52. 3
      tests/tabs/demo.test.js
  53. 3
      tests/tag/demo.test.js
  54. 3
      tests/time-picker/demo.test.js
  55. 3
      tests/timeline/demo.test.js
  56. 3
      tests/tooltip/demo.test.js
  57. 3
      tests/transfer/demo.test.js
  58. 3
      tests/tree-select/demo.test.js
  59. 3
      tests/tree/demo.test.js
  60. 3
      tests/upload/demo.test.js

5
.babelrc

@ -1,3 +1,6 @@
{
"presets": ["es2015", "react", "stage-0"]
"presets": ["es2015", "react", "stage-0"],
"plugins": [
"add-module-exports"
]
}

1
.gitignore

@ -30,3 +30,4 @@ config/base.yaml
components/**/*.js
components/**/*.jsx
/.vscode/
/coverage

15
.jest.node.json

@ -0,0 +1,15 @@
{
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"md"
],
"transform": {
"\\.tsx?$": "node_modules/typescript-babel-jest",
"tests/.*\\.js$": "node_modules/babel-jest",
"\\.md$": "node_modules/antd-demo-jest"
},
"testRegex": "/tests/node/.*\\.test\\.js$",
"testEnvironment": "node"
}

3
.travis.yml

@ -4,3 +4,6 @@ language: node_js
node_js:
- "6"
after_script:
- cat ./coverage/lcov.info | node_modules/coveralls/bin/coveralls.js

2
components/table/demo/grouping-columns.md

@ -86,7 +86,7 @@ for (let i = 0; i < 100; i++) {
data.push({
key: i,
name: 'John Brown',
age: Math.ceil(Math.random() * 100),
age: i + 1,
street: 'Lake Park',
building: 'C',
number: 2035,

4
components/transfer/demo/basic.md

@ -22,12 +22,12 @@ for (let i = 0; i < 20; i++) {
key: i.toString(),
title: `content${i + 1}`,
description: `description of content${i + 1}`,
disabled: Math.random() * 3 < 1,
disabled: i % 3 < 1,
});
}
const targetKeys = mockData
.filter(() => Math.random() * 2 > 1)
.filter(item => +item.key % 3 > 1)
.map(item => item.key);
const App = React.createClass({

1
components/upload/index.tsx

@ -71,6 +71,7 @@ export default class Upload extends React.Component<UploadProps, any> {
listType: 'text', // or pictrue
className: '',
disabled: false,
supportServerRender: true,
};
recentUploadStatus: boolean | PromiseLike<any>;

35
package.json

@ -78,20 +78,22 @@
"devDependencies": {
"@types/react": "~0.14.41",
"@types/react-dom": "~0.14.18",
"antd-demo-jest": "^1.0.5",
"antd-tools": "0.14.2",
"babel-cli": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"babel-eslint": "^7.1.0",
"babel-jest": "^17.0.0",
"babel-plugin-import": "^1.0.0",
"babel-plugin-transform-runtime": "~6.15.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"bisheng": "^0.17.0",
"bisheng-plugin-antd": "~0.6.0",
"bisheng-plugin-description": "^0.1.1",
"bisheng-plugin-react": "^0.3.0",
"bisheng-plugin-toc": "^0.3.0",
"coveralls": "^2.11.15",
"css-split-webpack-plugin": "^0.2.1",
"dekko": "^0.2.0",
"dora-plugin-upload": "^0.3.1",
@ -107,6 +109,7 @@
"eslint-plugin-markdown": "*",
"eslint-plugin-react": "^6.1.2",
"eslint-tinker": "^0.4.0",
"glob": "^7.1.1",
"history": "^4.4.0",
"jest": "^17.0.1",
"jest-cli": "^17.0.0",
@ -133,7 +136,8 @@
"react-sublime-video": "^0.2.0",
"reqwest": "^2.0.5",
"typescript-babel-jest": "^0.1.5",
"values.js": "^1.0.3"
"values.js": "^1.0.3",
"xhr2": "^0.1.3"
},
"babel": {
"presets": [
@ -143,7 +147,7 @@
]
},
"scripts": {
"test": "npm run lint && npm run dist && npm run jest && npm run site",
"test": "npm run lint && npm run dist && npm run jest -- --coverage -w 2 && npm run jest:node -- -w 2 && npm run site",
"lint": "npm run tslint && npm run eslint && npm run demolint && npm run lesshint",
"tslint": "antd-tools run ts-lint && npm run compile && rm -rf lib",
"eslint": "eslint test site scripts ./.eslintrc.js ./webpack.config.js --ext '.js,.jsx,.tsx' --ignore-pattern '!.eslintrc.js'",
@ -151,7 +155,8 @@
"lesshint": "lesshint components -r scripts/lesshint-report.js",
"eslint-fix": "eslint --fix test site scripts ./.eslintrc.js ./webpack.config.js --ext '.js,.jsx,.tsx' --ignore-pattern '!.eslintrc.js' && eslint-tinker ./components/*/demo/*.md",
"jest": "jest --no-cache",
"jest": "jest",
"jest:node": "jest --config .jest.node.json",
"clean": "antd-tools run clean",
"dist": "antd-tools run dist && node ./tests/dekko/dist.test.js",
@ -174,19 +179,29 @@
"tsx",
"js",
"jsx",
"json"
"json",
"md"
],
"modulePathIgnorePatterns": [
"/_site/"
],
"testPathIgnorePatterns": [
"dekko",
"/node_modules/"
"/node_modules/",
"node"
],
"transform": {
".*": "node_modules/typescript-babel-jest"
"\\.tsx?$": "node_modules/typescript-babel-jest",
"tests/.*\\.js$": "node_modules/babel-jest",
"\\.md$": "node_modules/antd-demo-jest"
},
"testRegex": "(/tests/.*|\\.(test|spec))\\.(js)$"
"testRegex": "/tests/.*\\.test\\.js$",
"coveragePathIgnorePatterns": [
"/node_modules/",
"components/.*/demo",
"/dist/",
"/tests/"
]
},
"pre-commit": [
"lint"

3
tests/affix/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('affix');

3
tests/alert/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('alert');

3
tests/anchor/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('anchor');

3
tests/auto-complete/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('auto-complete');

3
tests/back-top/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('back-top');

3
tests/badge/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('badge');

3
tests/breadcrumb/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('breadcrumb');

0
tests/__snapshots__/button.test.js.snap → tests/button/__snapshots__/index.test.js.snap

3
tests/button/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('button');

2
tests/button.test.js → tests/button/index.test.js

@ -1,7 +1,7 @@
import React from 'react';
import { render } from 'enzyme';
import { renderToJson } from 'enzyme-to-json';
import Button from '../components/button/button';
import Button from '../../components/button';
describe('Button', function() {
it('renders correctly', () => {

3
tests/calendar/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('calendar');

3
tests/card/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('card');

12
tests/carousel/demo.test.js

@ -0,0 +1,12 @@
import demoTest from '../shared/demoTest';
// https://github.com/WickyNilliams/enquire.js/issues/82
window.matchMedia = window.matchMedia || function() {
return {
matches : false,
addListener : function() {},
removeListener: function() {}
};
};
demoTest('carousel');

3
tests/checkbox/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('checkbox');

3
tests/collapse/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('collapse');

3
tests/date-picker/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('date-picker');

3
tests/dropdown/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('dropdown');

3
tests/form/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('form');

3
tests/grid/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('grid');

2
tests/icon.test.js → tests/icon/index.test.js

@ -1,7 +1,7 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import { wrap } from 'react-stateless-wrapper';
import AntIcon from '../components/icon/index';
import AntIcon from '../../components/icon/index';
const Icon = wrap(AntIcon);
describe('Icon', function() {

3
tests/input-number/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('input-number');

3
tests/input/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('input');

2
tests/layout.test.js → tests/layout/index.test.js

@ -1,6 +1,6 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
let { Col, Row } = require('../components/grid/index');
let { Col, Row } = require('../../components/grid/index');
describe('Grid', function() {
it('should render Col', () => {

3
tests/locale-provider/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('locale-provider');

3
tests/mention/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('mention', { skip: true });

3
tests/menu/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('menu', { skip: true });

3
tests/message/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('message');

3
tests/modal/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('modal');

3
tests/notification/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('notification');

3
tests/pagination/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('pagination');

3
tests/popconfirm/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('popconfirm');

3
tests/popover/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('popover');

2
tests/popover.test.js → tests/popover/index.test.js

@ -1,6 +1,6 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import Popover from '../components/popover/index';
import Popover from '../../components/popover/index';
describe('Popover', function() {
it('should show overlay when trigger is clicked', () => {

3
tests/progress/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('progress');

3
tests/radio/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('radio');

3
tests/rate/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('rate');

3
tests/select/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('select');

16
tests/shared/demoTest.js

@ -0,0 +1,16 @@
import glob from 'glob'
import { render } from 'enzyme';
import { renderToJson } from 'enzyme-to-json';
export default function demoTest(component, options = {}) {
const testMethod = options.skip ? test.skip : test;
const files = glob.sync(`./components/${component}/demo/*.md`);
files.forEach(file => {
testMethod(`renders ${file} correctly`, () => {
const demo = require('../.' + file);
const wrapper = render(demo);
expect(renderToJson(wrapper)).toMatchSnapshot();
});
});
}

3
tests/slider/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('slider');

3
tests/spin/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('spin');

3
tests/steps/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('steps');

3
tests/switch/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('switch');

3
tests/table/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('table');

3
tests/tabs/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('tabs');

3
tests/tag/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('tag');

3
tests/time-picker/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('time-picker');

3
tests/timeline/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('timeline');

3
tests/tooltip/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('tooltip');

3
tests/transfer/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('transfer');

3
tests/tree-select/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('tree-select');

3
tests/tree/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('tree');

3
tests/upload/demo.test.js

@ -0,0 +1,3 @@
import demoTest from '../shared/demoTest';
demoTest('upload');
Loading…
Cancel
Save