Skip to content

Commit

Permalink
Generate screenshots of stories (cruise-automation#26)
Browse files Browse the repository at this point in the history
This is an intermediate step before adding
https://github.com/reg-viz/reg-suit for screenshot tests.

I did a few other things in this PR:
- Moved inScreenshotTests files to the stories directory as we can now
  share code.
- When doing that I ran into an issue of eslint not liking the dot in
  `.storybook` imports, so I renamed that directory to `stories`. Bonus:
  this directory now gets properly linted!
- Also I had to add the root directory to webpack.config.js to be able
  to refer to `storybook/inScreenshotTests`.
- And when doing that I discovered that eslint-import-resolver-webpack
  didn’t pick up the root webpack.config.js properly in some cases, so
  I had to change .eslintrc.yml to .eslintrc.js so I could use __dirname
  to explicitly point to the right file.

Also I had to add the withScreenshots decorator to every story.

Test plan: tested locally; verified that it runs in CI.
  • Loading branch information
janpaul123 authored Dec 14, 2018
1 parent 8d6d83d commit 65e472a
Show file tree
Hide file tree
Showing 22 changed files with 628 additions and 211 deletions.
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2018-present, GM Cruise LLC
#
# This source code is licensed under the Apache License, Version 2.0,
# found in the LICENSE file in the root directory of this source tree.
# You may not use this file except in compliance with the License.

# See https://circleci.com/docs/2.0/language-javascript/
version: 2
jobs:
Expand Down Expand Up @@ -44,6 +50,10 @@ jobs:
name: "npm run build"
command: npm run build

- run:
name: "npm run screenshot-ci"
command: npm run screenshot-ci

- add_ssh_keys:
fingerprints:
- "d5:b8:7b:18:02:16:f1:90:6c:6d:34:b7:71:55:ae:b4"
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
coverage
build
/flow-typed
!.eslintrc.js
44 changes: 44 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = {
env: { browser: true, node: true, jest: true },
extends: [
"eslint:recommended",
"plugin:jest/recommended",
"plugin:react/recommended",
"plugin:flowtype/recommended",
"plugin:import/recommended",
"problems",
"plugin:prettier/recommended",
"prettier/flowtype",
"prettier/react",
],
plugins: ["jest", "import-order-alphabetical"],
parser: "babel-eslint",
settings: { "import/resolver": { webpack: { config: `${__dirname}/webpack.config.js` } } },
rules: {
curly: "error",
"prettier/prettier": "error",
"no-console": ["error", { allow: ["warn", "error"] }],
"no-unused-vars": ["error", { args: "none", varsIgnorePattern: "^_" }],
"flowtype/no-unused-expressions": "error",
"no-underscore-dangle": ["error", { allowAfterThis: true }],
"react/prop-types": "off", // We use Flow instead.
"no-useless-computed-key": "off", // https://github.com/facebook/flow/issues/380#issuecomment-224380551
yoda: "off", // https://github.com/RyanZim/eslint-config-problems/pull/1 and https://github.com/eslint/eslint/issues/10591
// Some good ones that people really should be adding to import/recommended:
"import/first": "error",
"import/no-self-import": "error",
"import/no-useless-path-segments": "error",
"import/no-mutable-exports": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error", // https://github.com/benmosher/eslint-plugin-import/issues/242#issuecomment-230118951
"no-duplicate-imports": "off", // False positives on flow type imports, so we use import/no-duplicates instead which handles them correctly.
// Group imports into two groups: packages and files. Sort alphabetically
// within those groups.
"import-order-alphabetical/order": [
"error",
{ "newlines-between": "always", groups: [["builtin", "external"], ["internal", "parent", "sibling", "index"]] },
],
// TODO(JP): Fix this instead of disabling it:
"import/no-named-as-default": "off",
},
};
50 changes: 0 additions & 50 deletions .eslintrc.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .storybook/addons.js

This file was deleted.

9 changes: 0 additions & 9 deletions .storybook/config.js

This file was deleted.

23 changes: 0 additions & 23 deletions .storybook/webpack.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion docs/src/jsx/withRanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from "react";

import inScreenshotTests from "./inScreenshotTests";
import inScreenshotTests from "stories/inScreenshotTests";

export default (fn) => {
class WithRange extends React.Component {
Expand Down
Loading

0 comments on commit 65e472a

Please sign in to comment.