2

I am developing an Angular application that uses the Jasmine framework for regular unit testing and the Cypress framework for end-to-end testing.

While I have had no trouble conducting my E2E tests with Cypress, the spec. files used with Jasmine inside my source code folder src all underline the toBe method calls in red and display the following error message:

TS2339: Property 'toBe' does not exist on type 'Assertion'

A code sample for one my tests is displayed below:

it('Should have a category of \'A\'', () => {(
    expect(category.category).toBe('A');
})

After doing research, I have discovered that the problem is due to both frameworks using the same assertion library. I have tried applying solutions from the following two posts but neither have worked.

Both solutions suggest editing one or more of the tsconfigjson files, though since I have started to use Cypress at version 10 and above, the cypress root folder has not come with its own config file.

liberlux
  • 85
  • 8
  • What angular version are you on? – Andrew Allen Dec 19 '22 at 15:04
  • I am on version 13.3.12 – liberlux Dec 19 '22 at 15:11
  • 1
    `tsconfig.json` is something independent of Cypress - it is a configuration file for TypeScript, and Cypress does not create one when it does it's initial setup. You can easily make your own in `cypress/` and follow the instructions in the answer for the second post to set up exclusions that avoid your issue. – agoff Dec 19 '22 at 15:21
  • 1
    I followed the solution for the second post and it seems to have worked. Thank you! – liberlux Dec 19 '22 at 15:52

0 Answers0