sequelize / cli

The Sequelize CLI
MIT License
2.53k stars 528 forks source link

Tests are stuck #1365

Closed b1ek closed 1 year ago

b1ek commented 1 year ago

Im working on a new feature for this and i want to add tests for it, but even running tests with no modifications produces this kind of thing:

yarn run v1.22.19
$ npm run lint && npm run build && npm run test-raw

> sequelize-cli@6.3.0 lint
> eslint test src

> sequelize-cli@6.3.0 build
> npm run build-clean && babel src -d lib && npm run build-bin && npm run build-assets

> sequelize-cli@6.3.0 build-clean
> rm -rf ./lib/

Successfully compiled 28 files with Babel (474ms).

> sequelize-cli@6.3.0 build-bin
> mv ./lib/sequelize.js ./lib/sequelize && chmod +x ./lib/sequelize

> sequelize-cli@6.3.0 build-assets
> cp -R ./src/assets ./lib/

> sequelize-cli@6.3.0 test-raw
> mocha 'test/**/*.test.js'

  [SQLITE] lib/sequelize db:migrate (JSON)
    1) creates the respective table

  0 passing (30s)
  1 failing

  1) [SQLITE] lib/sequelize db:migrate (JSON)
       creates the respective table:
     Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/home/blek/Documents/junk/seqcli-refresh/test/db/migrate-json.test.js)
      at listOnTimeout (node:internal/timers:569:17)
      at processTimers (node:internal/timers:512:7)

Is this a common thing to happen? I am unsure if that's just a platform thing or the code thing. I debugged it so far to test/db/migrate.test.js:289, but that block of code has been intact for 8 years, there's no way it could go unfixed for that long

I searched the issue tracker for this, but didn't have any luck

WikiRik commented 1 year ago

We're running these tests using GitHub Actions quite frequently and those work using yarn test without failures. So it might be on your end. Does this happen for other dialects as well? See this file for the other dialects used in CI and the required env variables for them; https://github.com/sequelize/cli/blob/main/.github/workflows/ci.yml

b1ek commented 1 year ago

I just checked them, none of them worked for me.

As of now i checked these platforms:

None of them are running tests at all. I am running tests with this:

$ export DIALECT=sqlite
$ yarn test

Other dialects didn't work too. I followed the scenario step-by-step in a clean chroot so i just dont imagine how is this working in the CI but not on my machine.

WikiRik commented 1 year ago

I'm using a clean GitHub Codespaces and ran yarn install && yarn test and then it works fine for sqlite tests. It is using Node 20.4.0 but using Node 18.16.1 also works for me.

Does sequelize itself give a table name back when debugging? https://github.com/sequelize/cli/blob/6bfc4dd3b2c1d9b806b9e54afdbd83322f4aa24b/test/support/helpers.js#L196-L203

b1ek commented 1 year ago

I am unsure what exactly are you asking, but running it with DEBUG=* may show better picture of what happened:

  mocha:runner run(): starting +22ms
  mocha:runner run(): emitting start +0ms

  mocha:runner run(): emitted start +0ms
  mocha:runner runSuite(): running  +1ms

  mocha:runner _addEventListener(): adding for event error; 0 current listeners +0ms
  mocha:runner runSuite(): running [SQLITE] lib/sequelize db:create +1ms
  mocha:runner runSuite(): bailing +0ms
  mocha:runner runSuite(): running [SQLITE] lib/sequelize db:drop +0ms
  mocha:runner runSuite(): bailing +0ms
  mocha:runner runSuite(): running [SQLITE] lib/sequelize db:migrate (JSON) +0ms
  [SQLITE] lib/sequelize db:migrate (JSON)
  mocha:runner _addEventListener(): adding for event error; 0 current listeners +1ms
  sequelize:connection:sqlite connection acquired default +0ms
  sequelize:sql:sqlite Executing (default): SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence'; +0ms
  sequelize:sql:sqlite Executed (default): SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence'; +0ms
  sequelize:sql:sqlite Executing (default): PRAGMA foreign_keys = OFF +4ms
  sequelize:sql:sqlite Executed (default): PRAGMA foreign_keys = OFF +0ms
  sequelize:sql:sqlite Executing (default): PRAGMA foreign_keys = ON +1ms
  sequelize:sql:sqlite Executed (default): PRAGMA foreign_keys = ON +0ms
  sequelize:pool pool created with max/min: 5/0, no replication +267ms
  mocha:runner _addEventListener(): adding for event error; 0 current listeners +8ms
  sequelize:connection:sqlite connection acquired default +489ms
  sequelize:sql:sqlite Executing (default): SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence'; +484ms
  sequelize:sql:sqlite Executed (default): SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence'; +0ms
  mocha:runner trapped unhandled rejection from (probably) user code; re-emitting on process +484ms
  mocha:runner _addEventListener(): adding for event unhandledRejection; 0 current listeners +0ms
  mocha:runner total number of failures: 1 +30s
b1ek commented 1 year ago

The tests for the main branch seem to run smoothly, i think that my code somehow affected the tests behaviour. Thanks for the help, though