Skip to content

Multiple cassettes for the same endpoint #22

@philippegirard

Description

@philippegirard

Hi,

I am wondering if there is a clean way to have multiple cassettes for the same endpoint and specify which one to use in a test case.

This would be useful when an endpoint might return different JSON body.

My current solution
This seams a bit a hacky to me, but it works.
I have created a folder architecture and each folder can record a different response for the same endpoint.

test('#saveCurrentUser authorized', async ()=> {
    fetch.configure({
      fixturePath: './_fixtures/authorized/'
    });
    // doing fetch to the endpoint example.com/api/test
    // this returns {"id":"e4130aaa-f5c","cip":"ciei200","enabled":true}
...

  test('#saveCurrentUser unauthorized', async () => {
    fetch.configure({
      fixturePath: './_fixtures/unauthorized/'
    });

   // doing fetch to the same endpoint example.com/api/test
   // this returns {"error":"invalid_token","error_description":"Invalid access token: 55e854e7b1b"}

Very good work on this lib ! It is very awesome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions