Skip to content

"Expected 1 arguments, but got 2." except with mysterious workaroundsΒ #65

@dskloetd

Description

@dskloetd

Bug

  • package version: 1.1.3
  • node version: 16.16.0
  • npm (or yarn) version: npm 8.11.0

What I tried initially

Initially the only things I did before using messages in expect were

  1. npm install --save-dev jest-expect-message
  2. Add import "jest-expect-message"; to jest-setup.ts.

This worked initially but after change the test and running the test again, I started getting:

> @dfinity/nns-dapp@2.0.17 test
> TZ=UTC jest "feature-flags.store.spec.ts"

 FAIL  src/tests/lib/stores/feature-flags.store.spec.ts
  ● Test suite failed to run

    src/tests/lib/stores/feature-flags.store.spec.ts:24:9 - error TS2554: Expected 1 arguments, but got 2.

    24         `FeatureFlag ${feature} should be exported from feature-flags.store.ts`
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        2.076 s
Ran all test suites matching /feature-flags.store.spec.ts/i.

What didn't work

I tried of all the following but the issue remained:

  1. Add "jest-expect-message", to setupFilesAfterEnv: in jest.config.cjs.
  2. Add "files": ["node_modules/jest-expect-message/types/index.d.ts"], to tsconfig.json
  3. Add "jest/valid-expect": "off", in rules: in .eslintrc.cjs.

What worked

  1. After running jest --clearCache the issue would go away, but return after making some changes and running the test again.
  2. npm install --save-dev @types/jest-expect-message made the issue go away consistently. However, the package is deprecated and when I look inside the package it looks basically empty. So I don't understand how this can have an effect.
  3. Using import "jest-expect-message"; in the test file itself rather than in jest-setup.ts works. Is this the intended way to use it?

Any insight into what might be going on would be greatly appreciated.

If you want, you can see our entire setup at dfinity/nns-dapp@main...kloet/jem3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions