Skip to content

Commit

Permalink
Intercept cy.request calls for API results upload (#324)
Browse files Browse the repository at this point in the history
* Add custom command for `cy.request`

* Replace context interface with stateful class

* Store requests & responses for later use

* Move context class to context file

* Replace copied Cypress v13 types with dependency

* Add command test file

* Use `spawn` instead of `exec`

* Fix spawn output

* Fix command integration test setup

* Add quotes

* Update integration setup

* Improve secret handling

* Add integration test draft

* Progress towards JSON upload

* Use `cy.task` for request interception

* Fix task handling

* Fix ESLint

* Update action

* Remove test execution issue keys

* Add `enqueueTask` tests

* Split tests into unit and integration

* Use different jobs in pipeline

* Add dependency to integration job

* Remove quotes

* Copy mocha call

* Add outgoing request tests

* Add incoming response tests

* Add command overwrite tests

* Add tests for `SimpleEvidenceCollection`

* Add tests for `PluginContext`

* Fix locale time tests

* Fix locale time tests

* Add evidence test

* Try pipeline fix

* Try pipeline fix

* Try pipeline fix

* Try pipeline fix

* Remove debug output

* Add more integration tests

* Simplify exports

* Always register plugin tasks

* Add documentation links
  • Loading branch information
csvtuda authored May 13, 2024
1 parent 807d4ff commit 4b87a89
Show file tree
Hide file tree
Showing 34 changed files with 2,077 additions and 847 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"overrides": [
{
"files": ["src/**/*.ts", "test/**/*.ts", "index.ts", "index.spec.ts"],
"files": ["*.spec.ts"],
"rules": {
// Clashes with sinon/chai assertions like: expect(method).to.not.have.been.called
"@typescript-eslint/unbound-method": "off"
Expand Down
37 changes: 35 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
pull-requests: write

jobs:
run-tests:
run-unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -24,10 +24,11 @@ jobs:
- run: npm install
- run: npm run build
- run: npm run eslint
- run: npm run coverage
- run: npm run test:coverage
- uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: Unit Test Results
files: |
.mocha/**/*.json
time_unit: milliseconds
Expand All @@ -37,3 +38,35 @@ jobs:
name: coverage-report
path: coverage
retention-days: 30

run-integration-tests:
runs-on: ubuntu-latest
needs: run-unit-tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/
cache: npm
- run: npm install
- run: npm run build
- run: npm run test:integration
env:
CYPRESS_JIRA_API_TOKEN_CLOUD: ${{ secrets.CYPRESS_JIRA_API_TOKEN_CLOUD }}
CYPRESS_JIRA_PASSWORD_SERVER: ${{ secrets.CYPRESS_JIRA_PASSWORD_SERVER }}
CYPRESS_JIRA_PROJECT_KEY_CLOUD: ${{ secrets.CYPRESS_JIRA_PROJECT_KEY_CLOUD }}
CYPRESS_JIRA_PROJECT_KEY_SERVER: ${{ secrets.CYPRESS_JIRA_PROJECT_KEY_SERVER }}
CYPRESS_JIRA_URL_CLOUD: ${{ secrets.CYPRESS_JIRA_URL_CLOUD }}
CYPRESS_JIRA_URL_SERVER: ${{ secrets.CYPRESS_JIRA_URL_SERVER }}
CYPRESS_JIRA_USERNAME_CLOUD: ${{ secrets.CYPRESS_JIRA_USERNAME_CLOUD }}
CYPRESS_JIRA_USERNAME_SERVER: ${{ secrets.CYPRESS_JIRA_USERNAME_SERVER }}
CYPRESS_XRAY_CLIENT_ID_CLOUD: ${{ secrets.XRAY_CLIENT_ID }}
CYPRESS_XRAY_CLIENT_SECRET_CLOUD: ${{ secrets.XRAY_CLIENT_SECRET }}
- uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: Integration Test Results
files: |
.mocha/**/*.json
time_unit: milliseconds
2 changes: 1 addition & 1 deletion .nycrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"check-coverage": true,
"exclude": ["**/*.spec.ts", "test/"],
"exclude": ["**/*.spec.ts", "test/", "dist/"],
"reporter": ["html", "text-summary"]
}
6 changes: 2 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
import { configureXrayPlugin, syncFeatureFile } from "./src/plugin";
import { Options } from "./src/types/plugin";

export { Options as CypressXrayPluginOptions, configureXrayPlugin, syncFeatureFile };
export { configureXrayPlugin, syncFeatureFile } from "./src/plugin";
export { CypressXrayPluginOptions } from "./src/types/plugin";
Loading

0 comments on commit 4b87a89

Please sign in to comment.