Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic testing setup (Demo) #591

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ _site
.eslintrc.js
.idea
.prettierignore
babel.config.js
beemo-error.log
coverage
dist
Expand Down
62 changes: 45 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lint-staged": "^10.0.2",
"monaco-editor-webpack-plugin": "^1.8.2",
"postcss-loader": "^3.0.0",
"prettier": "^1.19.1",
"react-test-renderer": "^16.12.0",
"style-loader": "^1.1.3",
"typescript": "~3.7.5",
"vega-lite-dev-config": "^0.3.1",
Expand Down Expand Up @@ -62,6 +62,24 @@
"vega-themes": "^2.6.0",
"vega-tooltip": "^0.20.0"
},
"scripts": {
"start": "webpack-dev-server --mode development --hot",
"start:production": "webpack-dev-server --mode production",
"build": "yarn clean && yarn vendor && webpack --mode production --progress",
"clean": "rm -rf dist public/spec public/data",
"postbuild": "rsync -r --ignore-existing public/* dist",
"generate-example-images": "scripts/generate-example-images.sh",
"vendor": "scripts/vendor.sh",
"prepare": "yarn vendor && beemo create-config --react",
"prettierbase": "beemo prettier '{src,public}/**/*.{css,html}'",
"eslintbase": "beemo eslint 'src/**/*.{ts,tsx}' --react",
"format": "yarn eslintbase --fix && yarn prettierbase --write",
"lint": "yarn eslintbase && yarn prettierbase --check",
"predeploy": "yarn build",
"deploy": "gh-pages -d dist",
"test": "jest test",
"analyze": "webpack --mode production --profile --json > stats.json && webpack-bundle-analyzer stats.json"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
Expand All @@ -80,6 +98,7 @@
"beemo": {
"module": "vega-lite-dev-config",
"drivers": [
"babel",
"prettier",
"eslint"
],
Expand All @@ -97,21 +116,30 @@
}
}
},
"scripts": {
"start": "webpack-dev-server --mode development --hot",
"start:production": "webpack-dev-server --mode production",
"build": "yarn clean && yarn vendor && webpack --mode production --progress",
"clean": "rm -rf dist public/spec public/data",
"postbuild": "rsync -r --ignore-existing public/* dist",
"generate-example-images": "scripts/generate-example-images.sh",
"vendor": "scripts/vendor.sh",
"prepare": "yarn vendor && beemo create-config --react",
"prettierbase": "beemo prettier '{src,public}/**/*.{css,html}'",
"eslintbase": "beemo eslint 'src/**/*.{ts,tsx}' --react",
"format": "yarn eslintbase --fix && yarn prettierbase --write",
"lint": "yarn eslintbase && yarn prettierbase --check",
"predeploy": "yarn build",
"deploy": "gh-pages -d dist",
"analyze": "webpack --mode production --profile --json > stats.json && webpack-bundle-analyzer stats.json"
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"moduleNameMapper": {
"\\.(css|less|scss|sass)$": "<rootDir>/test/mocks/style.js"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"testPathIgnorePatterns": [
"<rootDir>/node_modules",
"<rootDir>/dist",
"<rootDir>/src"
],
"transformIgnorePatterns": [
"node_modules/(?!(monaco-editor)/)"
],
"collectCoverage": false
}
}
8 changes: 8 additions & 0 deletions test/config-editor.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import renderer from 'react-test-renderer';
import ConfigEditor from '../src/components/config-editor';

test('config editor', () => {
const tree = renderer.create(<ConfigEditor />).toJSON();
expect(tree).toMatchSnapshot();
});
1 change: 1 addition & 0 deletions test/mocks/style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"importHelpers": true
},
"files": ["src/index.tsx"],
"include": ["node_modules/vega-lite/typings/*.d.ts"],
"include": ["test/**/*"],
"awesomeTypescriptLoaderOptions": {
"useCache": true,
"forceIsolatedModules": true,
Expand Down
Loading