https://cypress.io logo
Dynamic Test Runner
# i-need-help
f
Hello Community, I'm building a dynamic test runner that reads fixtures and creates tests for each of the items of the fixtures. The system under test is a REST API. Each fixture is an array of "test cases", one fixture per endpoint. For example, we have one actions.json fixture containing a list of cases. Each fixture looks like this:
Copy code
[
  {
    "name": "Should get 2 actions",
    "type": "case",
    "test_config": {
      "method": "GET",
      "endpoint": "/actions",
      "query_parameters": {
        "limit": 2
      }
    },
    "expected": {
      "status_code": 200
    }
  },
  ...
]
Then, a fixture called cases.json specifies which fixtures are needed to run:
Copy code
["actions", "users", etc]
All of this is to allow teams to only write fixtures for their endpoints, and our CI process compiles the required parts and executes the desired test cases. I'm struggling to find a proper strategy to load the fixtures. Using the cy.fixture command ties me to run it inside an it() block and that is complicating things and leading me to nasty
let
workarounds... Do you have any suggestion? Should I load the json files from the FS using cy.task? Thanks in advance
g
Use cypress-each
f
I'll take a look at that! thx