Skip to content

Commit

Permalink
Merge pull request #28 from betrybe/add-json-server
Browse files Browse the repository at this point in the history
Add json server
  • Loading branch information
antoniosb authored Nov 24, 2023
2 parents c84d7fd + 118f4a7 commit 37bd982
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ This action evaluate Tryber projects with [Cypress](https://www.npmjs.com/packag

Pull Request author username.

- `json-server`

**Default: false**

Initiate json-server start script before testing.

- `json-server-port`

**Default: 3050**

Define json-server port.

- `json-server-db`

**Default: db.json**

Define json-server db file.


## Outputs

- `result`
Expand Down
15 changes: 14 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,26 @@ inputs:
pr_author_username:
description: "Pull Request author username"
required: true
json-server:
description: "Initiate json-server start script before testing"
default: false
json-server-port:
description: "Define json-server port"
default: "3050"
json-server-db:
description: "Define json-server db file"
default: "db.json"

outputs:
result:
description: "Cypress unit tests JSON results in base64 format."
runs:
using: "docker"
image: "docker://betrybe/cypress-evaluator-action:v8.2"
image: "docker://betrybe/cypress-evaluator-action:v9.0"
args:
- ${{ inputs.npm-start }}
- ${{ inputs.headless }}
- ${{ inputs.browser }}
- ${{ inputs.json-server }}
- ${{ inputs.json-server-port }}
- ${{ inputs.json-server-db }}
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -x
RUN_NPM_START=$1
CYPRESS_HEADLESS=$2
CYPRESS_BROWSER=$3
RUN_JSON_SERVER=$4
JSON_SERVER_PORT=$5
JSON_SERVER_DB=$6

export CY_CLI=true

Expand All @@ -14,6 +17,11 @@ if $RUN_NPM_START ; then
npx wait-on -t 300000 $wait_for_url # wait for server until timeout
fi

if $RUN_JSON_SERVER ; then
npx json-server --watch $JSON_SERVER_DB --port $JSON_SERVER_PORT &
npx wait-on -t 300000 http://localhost:$JSON_SERVER_PORT
fi

headless_flag=''
if $CYPRESS_HEADLESS ; then
headless_flag="--headless"
Expand Down

0 comments on commit 37bd982

Please sign in to comment.