# C8Y application does not recognize Jest functions

**URL:** <https://community.cumulocity.com/t/c8y-application-does-not-recognize-jest-functions/246>\
**Category:** Forum\
**Tags:** cumulocity\
**Created:** [February 22, 2024, 5:05pm UTC](https://community.cumulocity.com/t/c8y-application-does-not-recognize-jest-functions/246 "2024-02-22T17:05:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luclib](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@luclib](https://community.cumulocity.com/u/luclib)\
**Post date:** [February 22, 2024, 5:05pm UTC](https://community.cumulocity.com/t/c8y-application-does-not-recognize-jest-functions/246/1 "2024-02-22T17:05:45Z")

</div>

I am running unit tests in my C8Y application with Jest and I am noticing that the TS compiler is not recognizing the methods from the Jest framework and keeps underlying them in red.

1. ![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/8/a/8ab512ae56bf5a399dc90075b8f5df7b6fa4cfbe.png)  
If I hover over `expect`, it thinks that I am calling the `expect` method from the Chai framework.

2. ![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/8/2/82af399848da4794380f6a90f2491ff7a9aced0b.png)  
When I hover over `it`, it thinks I am referring to the `it` method from Mocha.

To be clear, I can still run the unit tests with `npm test` and they work as intended.

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/4/3/4324329c63586bf825581d7a8b6b6dca023c7115.png)

This is only a problem when I try to build my application, as it reports them as errors and stops the build.

I have checked the configuration files for TS and Jest, and they seem to be in order.

**ts.config.spec.json**

```auto
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/spec",
    "types": ["jest"],
    "esModuleInterop": true
  },
  "include": ["src/ **/*.spec.ts", "src/** /*.d.ts"]
}

```

**setup-jest.js**

```auto
import 'jest-preset-angular/setup-jest';

```

**jest.config.js**

```auto
module.exports = {
  preset: 'jest-preset-angular',
  setupFilesAfterEnv: ['<rootDir>/setup-jest.js'],
  transformIgnorePatterns: ['/!node_modules\\/lodash-es/']
};

```

---

<div class="post-metadata">

**Author:** ![Christian\_Guether1](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/christian_guether1/32/14848_2.png) [@Christian\_Guether1](https://community.cumulocity.com/u/Christian_Guether1)\
**Post date:** [February 23, 2024, 6:42am UTC](https://community.cumulocity.com/t/c8y-application-does-not-recognize-jest-functions/246/2 "2024-02-23T06:42:27Z")

</div>

Hi Lucas,

do you have Cypress installed in the same project?

Best regards

  

* * *

Christian Guether

[Software AG Professional Services](https://www.softwareag.com/en_corporate/resources/services/professional-services.html)

[![](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/c/3/c3a93a2618e4708f51be40fe2e142061f7c4edc7.jpeg)](https://www.softwareag.com/en_corporate/resources/services/fast-track-services.html)

---

<div class="post-metadata">

**Author:** ![Tristan\_Bastian](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/tristan_bastian/32/18259_2.png) [@Tristan\_Bastian](https://community.cumulocity.com/u/Tristan_Bastian)\
**Post date:** [February 23, 2024, 11:00am UTC](https://community.cumulocity.com/t/c8y-application-does-not-recognize-jest-functions/246/3 "2024-02-23T11:00:58Z")

</div>

Hi Lucas.

this is not really an issue with it being a Cumulocity Web SDK application, but a general issue when using cypress and jest on the same project. The comment over here: [New Cypress 10 global TypeScript type conflicts with Jest `expect` · Issue #22059 · cypress-io/cypress · GitHub](https://github.com/cypress-io/cypress/issues/22059#issuecomment-1148921141) might help you.

Regards,  
Tristan

---

<div class="post-metadata">

**Author:** ![luclib](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@luclib](https://community.cumulocity.com/u/luclib)\
**Post date:** [February 23, 2024, 4:29pm UTC](https://community.cumulocity.com/t/c8y-application-does-not-recognize-jest-functions/246/4 "2024-02-23T16:29:38Z")

</div>

Hi Tristan, thanks for the input.

I was able to solve it with the suggestion posted here.

> <https://stackoverflow.com/questions/58999086/cypress-causing-type-errors-in-jest-assertions>

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [August 21, 2024, 4:30pm UTC](https://community.cumulocity.com/t/c8y-application-does-not-recognize-jest-functions/246/5 "2024-08-21T16:30:14Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
