filiphric / cypress-plugin-api

Cypress plugin to show your API information in the Cypress UI runner
ISC License
264 stars 35 forks source link

Cypress config env variable when defining get Property '<var_name>' does not exist on type 'Partial<PluginEnvOptions>' #107

Closed mluk-sastrify closed 1 year ago

mluk-sastrify commented 1 year ago

I'm using Cypress with Typescript, but when I am defining the variable with Cypress.env() command I am getting the following error in VSCode: image

cypress.config.ts content:

import { defineConfig } from 'cypress';

export default defineConfig({
  e2e: {
    baseUrl: 'http://localhost:4040',
    env: {
      apiServerUrl: 'http://localhost:7777/api',
  },
  setupNodeEvents(on, config) {
    // implement node event listeners here
  },
}
});

spec example: cypress/e2e/example.cy.ts (as per Cypress docs: https://docs.cypress.io/api/cypress-api/env#No-Arguments):

const { apiServerUrl } = Cypress.env();

describe('GET', () => {

  it('should GET all subscriptions', () => {
    cy.api({
      method: 'GET',
      url: `${apiServerUrl}/todo`,
    }).then(({ body, status }) => {
      expect(status).to.eq(200);
      expect(body).to.have.length(1);
    });
  });
});

If I add a empty string in params the error goes away: image

Seems to be related to: https://github.com/filiphric/cypress-plugin-api/issues/56

filiphric commented 1 year ago

Thanks for the report! I just released the fix with version 2.10.1

mluk-sastrify commented 1 year ago

Thanks, this is fixed now :)