title: Is it possible to test API endpoints with Playwright just like Cypress?
body: <p>I have been using Cypress for a while now but this new kid on the block has arrived, Playwright which resolves some of the pain points I had with Cypress. The best usage I have with Cypress though is using it as a central repository for both my API and UI tests.
  I was just wondering if this is possible with Playwright (and yes, I tried to google and check their documentation but maybe I missed something as it doesn't seem too explicit)</p>
  <p>For example, I have this test with assertions on body, status, and properties.
  <code>cypress/support/commands.js</code> (custom command)</p>
  <pre class="lang-js prettyprint-override"><code>Cypress.Commands.add('something', (method) =&gt; { // api for something
    return cy.request({
        method: method,
        url: 'https://something.com/api/',
        auth: {
          bearer: '12332asa42412412asda341'
        },
        body: 
          'description': 'this is my description'
        },
        headers: {
          'Content-Type': 'application/json'
        },
        failOnStatusCode: false // test all status codes
    });
  });
  </code></pre>
  <p><code>cypress/integration/apitest.js</code> (actual test)</p>
  <pre class="lang-js prettyprint-override"><code>   cy.something('POST').should((resp) =&gt; {
        expect(resp.status).to.eq(201);
        expect(resp.headers).to.have.property('content-type', 'application/json');
        expect(resp.body.description).to.eq('this is my description');
      });
  </code></pre>