Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Property 'calledWith' does not exist on type 'Assertion') error as soon as I add chai-http to my project #312

Closed
ziedHamdi opened this issue Feb 29, 2024 · 5 comments

Comments

@ziedHamdi
Copy link

ziedHamdi commented Feb 29, 2024

My project has a bunch of dependencies, I cannot know what is causing the issue, but as soon as I install chai-http I start having the following errors throughout the project (on npm run tsc):

tests/unit/services/config-service.unit.test.ts:43:54 - error TS2339: Property 'calledWith' does not exist on type 'Assertion'.

43       expect(SIDMClient.getAccessToken).to.have.been.calledWith('https://xyz');

The properties: called, calledWith, rejectedWith are not present anymore in the Assertion type.

This is my package.json dependencies

{
  "dependencies": {
    "@datadog/datadog-api-client": "^1.11.0",
    "aws-lambda": "^1.0.7",
    "aws-sdk": "^2.1448.0",
    "aws-serverless-express": "^3.4.0",
    "axios": "^1.3.1",
    "chai-http": "^4.4.0",
    "chai-uuid": "^1.0.6",
    "cookie-parser": "^1.4.6",
    "cors": "^2.8.5",
    "datadog-lambda-js": "^6.85.0",
    "dd-trace": "^3.9.3",
    "exphbs": "^1.2.0",
    "express": "^4.18.2",
    "express-opentracing": "^0.1.1",
    "form-data": "^4.0.0",
    "global-agent": "^3.0.0",
    "iso-3166-1": "^2.1.1",
    "iso-639-1": "^3.1.2",
    "jest": "^29.4.1",
    "jest-ts-auto-mock": "^2.1.0",
    "jose": "^1.28.2",
    "lodash": "^4.17.21",
    "lodash.clonedeepwith": "^4.5.0",
    "memoizee": "^0.4.15",
    "mongodb": "^4.17.0",
    "oidc-provider": "^6.31.1",
    "qs": "^6.11.0",
    "safe-stable-stringify": "^2.4.3",
    "samlify": "^2.8.7",
    "sanitize-html": "^2.12.1",
    "serverless": "^3.25.1",
    "totp-generator": "^0.0.14",
    "ts-jest": "^29.0.5",
    "ttypescript": "^1.5.15",
    "uuid": "^9.0.0",
    "whatwg-url": "^11.0.0",
    "winston": "^3.8.2"
  },
  "devDependencies": {
    "@istanbuljs/nyc-config-typescript": "^1.0.2",
    "@types/aws-lambda": "^8.10.109",
    "@types/aws-serverless-express": "^3.3.5",
    "@types/body-parser": "^1.19.2",
    "@types/chai": "^4.3.12",
    "@types/chai-http": "^4.2.0",
    "@types/express": "^4.17.15",
    "@types/lodash": "^4.14.194",
    "@types/lodash.clonedeepwith": "^4.5.7",
    "@types/mocha": "^10.0.1",
    "@types/sanitize-html": "^2.11.0",
    "@types/sinon": "^10.0.13",
    "@types/supertest": "^2.0.12",
    "@typescript-eslint/eslint-plugin": "^5.46.1",
    "@typescript-eslint/parser": "^5.46.1",
    "assert": "^2.0.0",
    "aws-sdk-mock": "^5.8.0",
    "chai": "^4.4.1",
    "chai-as-promised": "^7.1.1",
    "chai-match": "^1.1.1",
    "cheerio": "^1.0.0-rc.12",
    "copy-webpack-plugin": "^11.0.0",
    "dotenv": "^16.0.3",
    "eslint": "^8.30.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-airbnb-base": "^15.0.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-import-resolver-typescript": "^3.5.2",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-json": "^3.1.0",
    "eslint-plugin-prettier": "^4.2.1",
    "fast-xml-parser": "^4.0.12",
    "husky": "^8.0.2",
    "inquirer": "^9.1.4",
    "jsonwebtoken": "^8.5.1",
    "lint-staged": "^11.2.6",
    "mocha": "^10.2.0",
    "mockdate": "^3.0.5",
    "mongodb-memory-server": "^8.10.2",
    "nanoid": "^3.3.4",
    "newman": "^5.3.2",
    "nock": "^13.2.9",
    "nodemon": "^2.0.20",
    "nyc": "^15.1.0",
    "prettier": "^2.8.1",
    "puppeteer": "^19.4.1",
    "serverless": "^3.27.0",
    "serverless-dynamodb": "^0.2.47",
    "serverless-offline": "^12.0.4",
    "serverless-plugin-typescript": "^2.1.4",
    "shelljs": "^0.8.5",
    "sinon": "^14.0.1",
    "sinon-chai": "^3.7.0",
    "supertest": "^6.3.3",
    "terser-webpack-plugin": "^5.3.6",
    "ts-auto-mock": "^3.6.4",
    "ts-loader": "^9.4.2",
    "ts-node": "^10.9.1",
    "ts-node-dev": "^2.0.0",
    "typescript": "^4.9.5",
    "webpack": "^5.75.0",
    "webpack-cli": "^5.0.1",
    "webpack-node-externals": "^3.0.0",
    "ws": "^8.11.0"
  },
@43081j
Copy link
Contributor

43081j commented Feb 29, 2024

im guessing this is actually thanks to sinon-chai

and that will be caused by chaijs/chai#1569

@ziedHamdi
Copy link
Author

It seems like the issue is in @types/chai: "4" which is imported by the project and missing the methods

@43081j
Copy link
Contributor

43081j commented Feb 29, 2024

ah sorry yes, i missed that it is a typescript error

i would've thought calledWith came from sinon-chai. i don't think chai has such a method

so maybe you need the types package for sinon-chai? or whichever package is providing the calledWith extension

@ziedHamdi
Copy link
Author

I'll check that out. But if I remove @types/chai from node_modules, the project manages to compile (so maybe that dependency should be a devDependency to avoid these side effects?)

@ziedHamdi
Copy link
Author

You are right!!!

Adding
"@types/chai-as-promised" and "@types/sinon-chai" solved the issue. Thanks for pointing that out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants