Closed akshaysgithub closed 4 years ago
@akshaysgithub could you send the actual error being thrown?
@akshaysgithub could you send the actual error being thrown?
[Container] 2020/08/14 14:28:32 Running command yarn mochawesome-merge > mochawesome.json
ERROR: Failed to merge reports
Error: Pattern ./mochawesome-report/mochawesome*.json matched no report files
at pattern (/codebuild/output/src308570643/src/github.com/company/magento-cypress/node_modules/mochawesome-merge/lib/index.js:14:11)
at Array.map (
Could you try providing a path pattern yourself instead of changing directory to $PWD/cypress/report
?
Something like this:
build:
commands:
- ls -al
- pwd
- npx wait-on http://localhost:3000 &
- npx cypress run --env MAGENTO_HOST=COMPANYDOMAIN.com
- yarn add mocha@5.2.0 mochawesome mochawesome-merge
- yarn mochawesome-merge ./cypress/report/mochawesome-report/*.json > ./cypress/report/mochawesome.json
- yarn marge mochawesome.json
- aws s3 sync $PWD/cypress/report/mochawesome-report/ s3://cypress.company.com/
Could you try providing a path pattern yourself instead of changing directory to
$PWD/cypress/report
?Something like this:
build: commands: - ls -al - pwd - npx wait-on http://localhost:3000 & - npx cypress run --env MAGENTO_HOST=COMPANYDOMAIN.com - yarn add mocha@5.2.0 mochawesome mochawesome-merge - yarn mochawesome-merge ./cypress/report/mochawesome-report/*.json > ./cypress/report/mochawesome.json - yarn marge mochawesome.json - aws s3 sync $PWD/cypress/report/mochawesome-report/ s3://cypress.company.com/
The changes almost worked, the merge worked, but the marge command is giving issues.
I have tried 2 options, one is to CD into the directory and run
yarn marge mochawesome.json
and
- yarn mochawesome-merge ./cypress/report/mochawesome-report/*.json > ./cypress/report/mochawesome-report/mochawesome.json
- yarn marge ./cypress/report/mochawesome-report/mochawesome.json
When I try cd into directory, it says file not found. I can confirm there is mochawesome.json in the mentioned directory.
Running command yarn mochawesome-merge ./cypress/report/mochawesome-report/*.json > ./cypress/report/mochawesome-report/mochawesome.json
[Container] 2020/08/14 18:01:45 Running command yarn marge ./cypress/report/mochawesome-report/mochawesome.json
yarn run v1.22.4
$ /codebuild/output/src645161999/src/github.com/company/magento-cypress/node_modules/.bin/marge ./cypress/report/mochawesome-report/mochawesome.json
✘ Some files could not be processed:./cypress/report/mochawesome-report/mochawesome.json
Unexpected token y in JSON at position 0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.[Container] 2020/08/14 18:01:46 Command did not exit successfully yarn marge ./cypress/report/mochawesome-report/mochawesome.json exit status 1
[Container] 2020/08/14 18:01:46 Phase complete: BUILD State: FAILED
[Container] 2020/08/14 18:01:46 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: yarn marge ./cypress/report/mochawesome-report/mochawesome.json. Reason: exit status 1
[Container] 2020/08/14 18:01:46 Entering phase POST_BUILD
[Container] 2020/08/14 18:01:46 Phase complete: POST_BUILD State: SUCCEEDED
[Container] 2020/08/14 18:01:46 Phase context status code: Message:
Many many thanks for all your help. :-)
So, the first error is probably because when you run yarn command_name
it runs command_name from within your project root, regardless if you do cd folder-name
before. That’s my assumption.
The second error is easily fixable. It happens because if you use the >
operator to write to the file, it will write all the yarn output to that file, including the first console message before actually running the command. That generates invalid JSON.
To fix it, just change the >
operator to the -o
option, like the following:
yarn mochawesome-merge ./cypress/report/*.json -o ./cypress/report/mochawesome-report/mochawesome.json
So, the first error is probably because when you run
yarn command_name
it runs command_name from within your project root, regardless if you docd folder-name
before. That’s my assumption.The second error is easily fixable. It happens because if you use the
>
operator to write to the file, it will write all the yarn output to that file, including the first console message before actually running the command. That generates invalid JSON.To fix it, just change the
>
operator to the-o
option, like the following:yarn mochawesome-merge ./cypress/report/*.json -o ./cypress/report/mochawesome-report/mochawesome.json
Adding the -o fixed the issues. Thanks a lot. Thank you very much. :-)
Hello,
I want to create a single html file with the library. It's failing to find the json files. I can see that the json files are generated.
Error :
2 Running command yarn mochawesome-merge > mochawesome.json
I tried going one directory up as well, no luck
Running command cd $PWD/cypress/report/
I can see that the json file is there.
Buildspec.yml
What am I doing wrong? Any ideas. Thank you. :-)