Repository navigation
meta(core): convert unit/instance tests to TypeScript - #18563
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The "options are not given" tests for destroy, increment, restore and save wrapped the returned promise in a synchronous `.to.not.throw()`, so they passed even if the call rejected. They now await the promise. In set.test.ts, `expect(date).not.to.be.NaN` could not fail for a Date object, so it now checks getTime(), and a duplicated assertion is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Replace the getTestDialectTeaser wrappers with plain titles (Model.build, Model#get, Model#isSoftDeleted, Model#previous), use the sequelize instance from the support file directly instead of aliasing it as current, and remove the "options tests" describes that only scoped a queryRaw stub. The stub is now created in the test and restored with sinon.restore() after each test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* origin/main: (54 commits) fix: use bind parameters in the Oracle catalog queries (sequelize#18498) meta: update mysql docker tag to v8.4.13 (sequelize#18577) meta: update dependency eslint-plugin-jsdoc to v65.4.0 (sequelize#18575) meta: update dependency node to v24.22.1 (sequelize#18574) meta: update dependency @oclif/core to ^5.1.9 (sequelize#18573) fix(core): skip removing foreign keys in dropAllTables when dropping with cascade (sequelize#18497) fix(core): drop each model only once in Sequelize#drop (sequelize#18572) fix(postgres): drop the enum types of a model when its table is dropped (sequelize#18554) fix(core): avoid lodash omit in the Model constructor (sequelize#18556) meta(core): support async functions in expectPerDialect (sequelize#18569) meta: update dependency ibm_db to ^4.1.0 (sequelize#18571) fix(core): make rejectInvalidOptions iterate supportable options and accept undefined (sequelize#18557) fix(core): respect the omitNull option of calls and models, fix query generator typings (sequelize#18565) meta(core): convert unit/model tests to TypeScript (sequelize#18564) meta(core): convert unit/instance tests to TypeScript (sequelize#18563) meta: update sequelize AUTHORS (sequelize#18549) feat(mssql): add useUnicodeStrings dialect option (sequelize#18548) meta: retry image pulls in the database start scripts (sequelize#18340) meta(core): follow-ups to the isModelStatic cache from sequelize#18234 (sequelize#18559) meta: update dependency uuid to v14 (sequelize#18544) ... # Conflicts: # packages/postgres/src/query-interface.js
* origin/main: (26 commits) fix: use bind parameters in the Oracle catalog queries (sequelize#18498) meta: update mysql docker tag to v8.4.13 (sequelize#18577) meta: update dependency eslint-plugin-jsdoc to v65.4.0 (sequelize#18575) meta: update dependency node to v24.22.1 (sequelize#18574) meta: update dependency @oclif/core to ^5.1.9 (sequelize#18573) fix(core): skip removing foreign keys in dropAllTables when dropping with cascade (sequelize#18497) fix(core): drop each model only once in Sequelize#drop (sequelize#18572) fix(postgres): drop the enum types of a model when its table is dropped (sequelize#18554) fix(core): avoid lodash omit in the Model constructor (sequelize#18556) meta(core): support async functions in expectPerDialect (sequelize#18569) meta: update dependency ibm_db to ^4.1.0 (sequelize#18571) fix(core): make rejectInvalidOptions iterate supportable options and accept undefined (sequelize#18557) fix(core): respect the omitNull option of calls and models, fix query generator typings (sequelize#18565) meta(core): convert unit/model tests to TypeScript (sequelize#18564) meta(core): convert unit/instance tests to TypeScript (sequelize#18563) meta: update sequelize AUTHORS (sequelize#18549) feat(mssql): add useUnicodeStrings dialect option (sequelize#18548) meta: retry image pulls in the database start scripts (sequelize#18340) meta(core): follow-ups to the isModelStatic cache from sequelize#18234 (sequelize#18559) meta: update dependency uuid to v14 (sequelize#18544) ... # Conflicts: # packages/core/src/abstract-dialect/query-generator.js # packages/core/src/abstract-dialect/query-interface-typescript.ts # packages/core/test/unit/model/bulk-create.test.js # packages/core/test/unit/sql/insert.test.js
Pull Request Checklist
Description of Changes
This converts the 11 remaining JavaScript tests in
test/unit/instanceto TypeScript, so the folder is now TypeScript only. The diffs are kept small so git detects the renames. Imports become ESM,Support.xbecomes named imports, and the mochathiscontext ingetandis-soft-deletedis replaced withbeforeEach2.The commits can be reviewed separately: the first one is the conversion, the second one fixes the assertions, and the third one follows up on review.
Suite names
Following review, the
getTestDialectTeaser('Instance')wrappers are gone. Each suite is named after the method it tests,Model.buildfor the static method andModel#get,Model#isSoftDeletedandModel#previousfor instance methods, like the other files in the folder. The files use thesequelizeinstance from the support file directly instead of aliasing it ascurrent.The
options testsdescribes indecrement,destroy,increment,reload,restoreandsaveonly scoped aqueryRawstub for a single test. They are removed: the stub is created in the test and restored withsinon.restore()after each test.Issues found by the type checker
build.test:timestamp: falsewas a typo fortimestamps: false.reload.test/restore.test:deletedAt: {}declared an attribute with no type. It made no difference at runtime, because paranoid models add thedeletedAtattribute themselves, so it is removed.set.teststubsqueryInterface.getNextPrimaryKeyValue, a@privatemethod of the JS query interface that is missing from the typings. The stub stays in place, cast to that method's shape.queryRawstubs indecrement,destroyandincrementresolved to a made-up model-like object that nothing read. They now resolve to[[], 0], like the other TypeScript unit tests.save,restoreandreloadneed a model-like result, because that is whatqueryRawreturns when it is called withinstanceorplain. Those stubs keep their values with anas anyand a comment, since thequeryRawoverloads can't express that return type.Assertions that could not fail
The stricter lint rules for TypeScript (
no-floating-promises) flagged that the "even if options are not given" tests fordestroy,increment,restoreandsavewere empty:These methods are async, so they never throw synchronously, and the test passed even if the promise rejected. The tests now
await expect(...).to.be.fulfilled. I checked that they do fail now when the stubbed result is wrong:save,restoreandreloadreject with aTypeErrorifqueryRawresolves to[[], 0].In
set.test,expect(user.get('date')).not.to.be.NaNcould not fail for aDateobject. It now checksgetTime(). A duplicated assertion is also removed.Verified:
tsc -b test/tsconfig.json, eslint, prettier, and the instance unit tests on all 9 dialects (sqlite3, postgres, mysql, mariadb, mssql, db2, ibmi, snowflake, oracle).List of Breaking Changes
None, tests only.
🤖 Generated with Claude Code
Summary by CodeRabbit