diff --git a/.teamcity/OpenSourceProjects_Storybook/buildTypes/OpenSourceProjects_Storybook_CliTest.kt b/.teamcity/OpenSourceProjects_Storybook/buildTypes/OpenSourceProjects_Storybook_CliTest.kt index 2761120f47d0..d724585270d6 100644 --- a/.teamcity/OpenSourceProjects_Storybook/buildTypes/OpenSourceProjects_Storybook_CliTest.kt +++ b/.teamcity/OpenSourceProjects_Storybook/buildTypes/OpenSourceProjects_Storybook_CliTest.kt @@ -23,7 +23,7 @@ object OpenSourceProjects_Storybook_CliTest : BuildType({ set -e -x yarn - yarn test --cli + yarn test --cli --teamcity """.trimIndent() dockerImage = "node:%docker.node.version%" } diff --git a/.teamcity/OpenSourceProjects_Storybook/buildTypes/OpenSourceProjects_Storybook_CliTestLatestCra.kt b/.teamcity/OpenSourceProjects_Storybook/buildTypes/OpenSourceProjects_Storybook_CliTestLatestCra.kt index 3daf4953f767..26b8e11d0485 100644 --- a/.teamcity/OpenSourceProjects_Storybook/buildTypes/OpenSourceProjects_Storybook_CliTestLatestCra.kt +++ b/.teamcity/OpenSourceProjects_Storybook/buildTypes/OpenSourceProjects_Storybook_CliTestLatestCra.kt @@ -26,7 +26,7 @@ object OpenSourceProjects_Storybook_CliTestLatestCra : BuildType({ set -e -x yarn - yarn test-latest-cra + yarn test-latest-cra -t """.trimIndent() dockerImage = "node:%docker.node.version%" } diff --git a/lib/cli/test/run_tests.sh b/lib/cli/test/run_tests.sh index 85a34400d10b..e303df181194 100755 --- a/lib/cli/test/run_tests.sh +++ b/lib/cli/test/run_tests.sh @@ -12,14 +12,19 @@ function cleanup { trap cleanup EXIT fixtures_dir='fixtures' +teamcity=0 # parse command-line options # '-f' sets fixtures directory -while getopts ":uosf:" opt; do +# '-t' adds teamcity reporting +while getopts ":tf:" opt; do case $opt in f) fixtures_dir=$OPTARG ;; + t) + teamcity=1 + ;; esac done @@ -49,7 +54,27 @@ for dir in * do # check that storybook starts without errors cd $dir + + if [ $teamcity -eq 1 ] + then + echo "##teamcity[testStarted name='$dir' captureStandardOutput='true']" + fi + echo "Running smoke test in $dir" - yarn storybook --smoke-test + failed=0 + yarn storybook --smoke-test || failed=1 + + if [ $teamcity -eq 1 ] + then + if [ $failed -eq 1 ] + then + echo "##teamcity[testFailed name='$dir']" + fi + echo "##teamcity[testFinished name='$dir']" + elif [ $failed -eq 1 ] + then + exit 1 + fi + cd .. done diff --git a/lib/cli/test/test_latest_cra.sh b/lib/cli/test/test_latest_cra.sh index dd24199e15dd..15849e0177ff 100755 --- a/lib/cli/test/test_latest_cra.sh +++ b/lib/cli/test/test_latest_cra.sh @@ -11,4 +11,4 @@ cd cra-fixtures npx create-react-app react-scripts-latest-fixture cd .. -./run_tests.sh -f cra-fixtures +./run_tests.sh -f cra-fixtures $@ diff --git a/package.json b/package.json index d6a4c547ef31..8a6a93adf62d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "repo-dirty-check": "node ./scripts/repo-dirty-check", "start": "yarn --cwd examples/official-storybook storybook", "test": "node ./scripts/test.js", - "test-latest-cra": "npm --prefix lib/cli run test-latest-cra" + "test-latest-cra": "yarn --cwd lib/cli run test-latest-cra" }, "devDependencies": { "@angular/common": "^7.0.1", diff --git a/scripts/test.js b/scripts/test.js index 726ebc090d59..6ade92aea5a7 100644 --- a/scripts/test.js +++ b/scripts/test.js @@ -100,7 +100,7 @@ const tasks = { name: `Use TeamCity reporter`, defaultValue: false, option: '--teamcity', - extraParam: '--testResultsProcessor=jest-teamcity-reporter', + extraParam: '-t --testResultsProcessor=jest-teamcity-reporter', }), };