-
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Storybook 5 in init command (#225)
- Loading branch information
Showing
11 changed files
with
118 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
generated |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "@loki/test-cli", | ||
"version": "0.20.1", | ||
"private": true, | ||
"scripts": { | ||
"test": "bash ./test-cra-init.sh" | ||
}, | ||
"devDependencies": { | ||
"execa": "^1.0.0", | ||
"loki": "^0.20.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
set -Eeuo pipefail | ||
|
||
assert_contains() { | ||
FILENAME=$1 | ||
EXPECTED_CONTENT=$2 | ||
|
||
if [[ "$(cat $FILENAME)" == *"${EXPECTED_CONTENT}"* ]]; then | ||
return 0 | ||
else | ||
echo "Unable to find $EXPECTED_CONTENT in $FILENAME" | ||
return 1 | ||
fi | ||
} | ||
|
||
# Ensure we're in the correct folder | ||
pushd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null | ||
|
||
# Scaffold a new CRA project with storybook and loki | ||
mkdir -p generated | ||
cd generated | ||
rm -rf create-react-app || true | ||
yarn create react-app create-react-app | ||
cd create-react-app | ||
npx -p @storybook/cli sb init | ||
yarn add loki | ||
../../../../node_modules/.bin/loki init | ||
|
||
# Ensure modifications has been made | ||
assert_contains "package.json" "$(cat <<-END | ||
"loki": { | ||
"configurations": { | ||
"chrome.laptop": { | ||
"target": "chrome.docker", | ||
"width": 1366, | ||
"height": 768, | ||
"deviceScaleFactor": 1, | ||
"mobile": false | ||
}, | ||
"chrome.iphone7": { | ||
"target": "chrome.docker", | ||
"preset": "iPhone 7" | ||
} | ||
} | ||
} | ||
END | ||
)" | ||
assert_contains ".storybook/preview.js" "import 'loki/configure-react'" | ||
|
||
# Ensure we can snap stories | ||
yarn build-storybook | ||
mkdir -p .loki/reference | ||
cp ../../fixtures/chrome_laptop_Welcome_to_Storybook.png ./.loki/reference | ||
../../../../node_modules/.bin/loki test laptop --requireReference --storiesFilter Welcome --reactUri file:./storybook-static | ||
|
||
# Peace out | ||
popd > /dev/null |