Jest in watch mode didn't work

Describe the issue/error/question

Jest is run in watch mode, but it seems not to catch the changes.

Please share the workflow

I’d like to develop my custom node in TDD,
then I set up a jest --watch in packages/nodes-base/package.json

  "scripts": {
    "dev": "npm run watch",
    "test": "jest",
    "test-watch": "jest --watch" <-- added

and I run it with lerna run test-watch under the root of the project.

I can see it run, but when I change something in the newly created node file,
no test run, nothing happens.

➜  n8n git:(feature/#8047-gllue-node-auth) βœ— lerna run test-watch
info cli using local version of lerna
lerna notice cli v3.22.1
lerna info versioning independent
lerna info Executing command in 1 package: "npm run test-watch"

Information on your n8n setup

  • n8n version: 0.149.0
  • Database you’re using (default: SQLite): Postgres
  • Running n8n with the execution process [own(default), main]: default
  • Running n8n via [Docker, npm,, desktop app]: npm

Could you try adding "test-watch": "jest --watch" to packages/nodes-base/package.json and running it from inside the package?


@ivov thanks! It works.

➜  nodes-base git:(feature/#8047-gllue-node-auth) βœ— pwd
➜  nodes-base git:(feature/#8047-gllue-node-auth) βœ— npm run test-watch

 FAIL  test/nodes/Gllue/helpers.test.ts
  Private Token Generator
    βœ“ should get current date string (2 ms)
    βœ“ should connect the data with comma (1 ms)
    βœ“ should pad string with 16 length with 15
    βœ“ should pad string with 16 length with 16
    βœ“ should pad string with 32 length with 17 (1 ms)
    βœ• should pad string with 48 length with 33 (2 ms)
    βœ“ should pad string with 48 length
    βœ“ should pad string with enough space (1 ms)
    βœ“ should generate token with AES KEY (1 ms)

  ● Private Token Generator β€Ί should pad string with 48 length with 33

    expect(received).toEqual(expected) // deep equality

    Expected: 48
    Received: 33120

      38 | 	it('should pad string with 48 length with 33', () => {
      39 | 		const realData = helpers.get16TimesLength(33111);
    > 40 | 		expect(realData).toEqual(3 * SCALE_SIZE);
         | 		                 ^
      41 | 	})
      42 | 	it('should pad string with 48 length', () => {
      43 | 		const realData = helpers.padWithSpaceIn16Times(TIMESTAMP_EMAIL_CONNECTED);

      at Object.<anonymous> (test/nodes/Gllue/helpers.test.ts:40:20)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 8 passed, 9 total
Snapshots:   0 total
Time:        1.341 s
Ran all test suites related to changed files.

Watch Usage
 β€Ί Press a to run all tests.
 β€Ί Press f to run only failed tests.
 β€Ί Press p to filter by a filename regex pattern.
 β€Ί Press t to filter by a test name regex pattern.
 β€Ί Press q to quit watch mode.
 β€Ί Press Enter to trigger a test run.
1 Like