From 29bb0e64441a4ea70e784c6b18afcc9522a70c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=B3=C5=82kowski?= Date: Fri, 18 Dec 2020 07:56:03 +0100 Subject: [PATCH] Storybook: Perform cleanup in the Storybook setup (#27786) * Storybook: Perform cleanup in the Storybook setup * Update the lock file after removing no longer used Babel plugin --- .eslintignore | 1 - .github/workflows/storybook-pages.yml | 2 +- .gitignore | 1 - docs/contributors/testing-overview.md | 3 +-- package-lock.json | 6 ------ package.json | 7 +------ storybook/.babelrc | 7 +------ test/unit/config/register-context.js | 6 ------ test/unit/jest.config.js | 1 - 9 files changed, 4 insertions(+), 30 deletions(-) delete mode 100644 test/unit/config/register-context.js diff --git a/.eslintignore b/.eslintignore index b6206ec553a90f..9a603c2bceb3d4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,7 +6,6 @@ node_modules packages/block-serialization-spec-parser/parser.js packages/e2e-tests/plugins packages/react-native-editor/bundle -playground/dist vendor wordpress !.*.js diff --git a/.github/workflows/storybook-pages.yml b/.github/workflows/storybook-pages.yml index 0c66e9b9e92e55..f3a956c75841d6 100644 --- a/.github/workflows/storybook-pages.yml +++ b/.github/workflows/storybook-pages.yml @@ -42,4 +42,4 @@ jobs: uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./playground/dist + publish_dir: ./storybook/build diff --git a/.gitignore b/.gitignore index cf7a035b43b060..d79599e194f3cf 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ yarn.lock /wordpress /artifacts -playground/dist .cache *.tsbuildinfo diff --git a/docs/contributors/testing-overview.md b/docs/contributors/testing-overview.md index c5d21a281e5df7..7616af58afacf0 100644 --- a/docs/contributors/testing-overview.md +++ b/docs/contributors/testing-overview.md @@ -355,9 +355,8 @@ It's tempting to snapshot deep renders, but that makes for huge snapshots. Addit Sometimes we need to mock refs for some stories which use them. Check the following documents to learn more: - Why we need to use [Mocking Refs for Snapshot Testing](https://reactjs.org/blog/2016/11/16/react-v15.4.0.html#mocking-refs-for-snapshot-testing) with React. -- [Using createNodeMock to mock refs](https://github.com/storybookjs/storybook/tree/master/addons/storyshots/storyshots-core#using-createnodemock-to-mock-refs) with StoryShots. -In that case, you might see test failures and `TypeError` reported by Jest in the lines which try to access a property from `ref.current`. If this happens, search for `initStoryshots` method call, which contains all necessary configurations to adjust. +In that case, you might see test failures and `TypeError` reported by Jest in the lines which try to access a property from `ref.current`. ### Debugging Jest unit tests diff --git a/package-lock.json b/package-lock.json index 7baee614bf0837..5ff4c540066cc6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24218,12 +24218,6 @@ "@babel/template": "^7.0.0-beta.49" } }, - "babel-plugin-require-context-hook": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/babel-plugin-require-context-hook/-/babel-plugin-require-context-hook-1.0.0.tgz", - "integrity": "sha512-EMZD1563QUqLhzrqcThk759RhuNVX/ZJdrtGK6drwzgvnR+ARjWyXIHPbu+tUNaMGtPz/gQeAM2M6VUw2UiUeA==", - "dev": true - }, "babel-plugin-syntax-jsx": { "version": "6.18.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz", diff --git a/package.json b/package.json index ecec9a29644009..759a5dc86c9d75 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,6 @@ "babel-plugin-inline-json-import": "0.3.2", "babel-plugin-react-native-classname-to-style": "1.2.2", "babel-plugin-react-native-platform-specific-extensions": "1.1.1", - "babel-plugin-require-context-hook": "1.0.0", "benchmark": "2.1.4", "browserslist": "4.15.0", "chalk": "4.0.0", @@ -262,13 +261,9 @@ "test-unit:native": "cd test/native/ && cross-env NODE_ENV=test jest --config ./jest.config.js", "test-unit:native:debug": "cd test/native/ && node --inspect ../../node_modules/.bin/jest --runInBand --config ./jest.config.js", "prestorybook:build": "npm run build:packages", - "storybook:build": "build-storybook -c ./storybook -o ./playground/dist", + "storybook:build": "build-storybook -c ./storybook -o ./storybook/build", "prestorybook:dev": "npm run build:packages", "storybook:dev": "concurrently \"npm run dev:packages\" \"start-storybook -c ./storybook -p 50240\"", - "design-system:build": "echo \"Please use storybook:build instead.\"", - "design-system:dev": "echo \"Please use storybook:dev instead.\"", - "playground:build": "npm run storybook:build", - "playground:dev": "echo \"Please use storybook:dev instead.\"", "env": "wp-scripts env", "wp-env": "wp-env" }, diff --git a/storybook/.babelrc b/storybook/.babelrc index b2b3e792e2f972..fe77bd84598748 100644 --- a/storybook/.babelrc +++ b/storybook/.babelrc @@ -3,10 +3,5 @@ "plugins": [ "babel-plugin-emotion", "babel-plugin-inline-json-import" - ], - "env": { - "test": { - "plugins": [ "babel-plugin-require-context-hook" ] - } - } + ] } diff --git a/test/unit/config/register-context.js b/test/unit/config/register-context.js deleted file mode 100644 index b73423550f42c6..00000000000000 --- a/test/unit/config/register-context.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * External dependencies - */ -import registerRequireContextHook from 'babel-plugin-require-context-hook/register'; - -registerRequireContextHook(); diff --git a/test/unit/jest.config.js b/test/unit/jest.config.js index fa37927d7c7c48..ee73efecd04029 100644 --- a/test/unit/jest.config.js +++ b/test/unit/jest.config.js @@ -19,7 +19,6 @@ module.exports = { setupFiles: [ '/test/unit/config/global-mocks.js', '/test/unit/config/gutenberg-phase.js', - '/test/unit/config/register-context.js', ], testURL: 'http://localhost', testPathIgnorePatterns: [