Repository navigation
Test suite follow-ups from the assertion audit #18521
Description
While auditing the test suite for assertions that cannot fail (#18509, #18520), we found more things that make tests weaker than they look. #18520 deliberately left these out, because they are judgement calls or need decisions per dialect rather than being plain bugs.
We haven't decided yet which of these, if any, we want to fix. This issue tracks the candidates so they don't get lost. Decide per item before opening a PR.
Line numbers are as of 241ba93. Some files are also touched by #18520, so lines may shift.
1. Tests that return early instead of skipping
62 tests return from inside the it() when a dialect doesn't support something. Mocha reports them as passed, although they ran nothing. Calling this.skip(), or moving the guard outside the it(), would report them as pending instead. Most are if (dialect.supports.schemas) return in unit/query-generator/*.
Full list
test/unit/pool.test.ts:76 | dialectName !== 'postgres'
test/unit/transaction.test.ts:95 | !sequelize.dialect.supports.savepoints
test/integration/instance.test.js:90 | !Support.sequelize.dialect.supports.upserts
test/integration/json.test.ts:67 | dialect.name === 'oracle' && !(await isOracleJSONConstraintsSupported())
test/integration/json.test.ts:163 | dialectName !== 'mariadb'
test/integration/json.test.ts:353 | ['mariadb', 'mysql', 'mssql'].includes(dialectName)
test/integration/configuration.test.ts:148 | dialectName !== 'sqlite3'
test/integration/model.test.js:1708 | !dialect.supports.dataTypes.BIGINT
test/unit/utils/sql.test.ts:252 | !supportsNonStandardConformingStrings()
test/unit/utils/sql.test.ts:661 | !supportsNonStandardConformingStrings()
test/unit/utils/sql.test.ts:940 | !supportsNonStandardConformingStrings()
test/integration/model/findOne.test.js:56 | dialectName === 'sqlite3'
test/integration/model/json.test.js:287 | dialect.name === 'oracle' && !(await Support.isOracleJSONConstraintsSupported())
test/integration/model/sync.test.js:543 | !sequelize.dialect.supports.schemas
test/integration/model/internals.test.ts:33 | dialectName === 'sqlite3'
test/integration/model/internals.test.ts:68 | dialectName === 'sqlite3'
test/integration/model/internals.test.ts:101 | dialectName === 'sqlite3'
test/integration/model/create.test.js:497 | ['sqlite3', 'mssql', 'db2', 'ibmi', 'oracle'].includes(dialectName)
test/integration/model/create.test.js:536 | dialectName === 'sqlite3'
test/integration/model/create.test.js:590 | dialectName === 'sqlite3'
test/integration/model/create.test.js:1016 | dialectName.startsWith('postgres')
test/integration/model/paranoid.test.js:125 | dialect.name === 'oracle' && !(await Support.isOracleJSONConstraintsSupported())
test/integration/sequelize/drop.test.ts:44 | !sequelize.dialect.supports.dropTable.cascade
test/integration/data-types/methods.test.ts:187 | !dialect.supports.upserts
test/integration/data-types/data-types.test.ts:1114 | dialect.name === 'mssql'
test/unit/model/validation.test.js:364 | !dialect.supports.dataTypes.ARRAY
test/unit/sql/literal.test.ts:169 | !dialect.supports.dataTypes.ARRAY
test/unit/query-interface/create-table.test.ts:124 | !dialect.supports.dataTypes.JSON
test/unit/query-interface/upsert.test.ts:30 | dialectName === 'oracle'
test/unit/query-interface/upsert.test.ts:113 | sequelize.dialect.supports.returnIntoValues
test/unit/query-interface/upsert.test.ts:174 | sequelize.dialect.supports.returnIntoValues
test/unit/query-interface/insert.test.ts:25 | dialect.supports.returnIntoValues
test/unit/query-interface/insert.test.ts:84 | dialect.supports.returnIntoValues
test/unit/query-interface/insert.test.ts:120 | dialect.supports.returnIntoValues
test/unit/query-generator/get-constraint-snippet.test.ts:179 | dialect.supports.schemas
test/unit/query-generator/get-constraint-snippet.test.ts:311 | dialect.supports.schemas
test/unit/query-generator/get-constraint-snippet.test.ts:445 | dialect.supports.schemas
test/unit/query-generator/get-constraint-snippet.test.ts:661 | dialect.supports.schemas
test/unit/query-generator/get-constraint-snippet.test.ts:811 | dialect.supports.schemas
test/unit/query-generator/describe-table-query.test.ts:486 | dialect.supports.schemas
test/unit/query-generator/create-table-query.test.ts:99 | dialect.supports.schemas
test/unit/query-generator/create-table-query.test.ts:339 | !dialect.supports.dataTypes.ARRAY
test/unit/query-generator/truncate-table-query.test.ts:130 | dialect.supports.schemas
test/unit/query-generator/truncate-table-query.test.ts:149 | dialect.supports.schemas
test/unit/query-generator/bulk-delete-query.test.ts:151 | dialect.supports.schemas
test/unit/query-generator/bulk-insert-query.test.ts:21 | dialect === 'oracle'
test/unit/query-generator/add-constraint-query.test.ts:182 | dialect.supports.schemas
test/unit/query-generator/add-constraint-query.test.ts:321 | dialect.supports.schemas
test/unit/query-generator/add-constraint-query.test.ts:468 | dialect.supports.schemas
test/unit/query-generator/add-constraint-query.test.ts:697 | dialect.supports.schemas
test/unit/query-generator/add-constraint-query.test.ts:858 | dialect.supports.schemas
test/unit/query-generator/table-exists-query.test.ts:90 | dialect.supports.schemas
test/unit/query-generator/remove-column-query.test.ts:88 | dialect.supports.schemas
test/unit/query-generator/rename-table-query.test.ts:131 | dialect.supports.schemas
test/unit/query-generator/remove-constraint-query.test.ts:122 | dialect.supports.schemas
test/unit/query-generator/show-constraints-query.test.ts:150 | dialect.supports.schemas
test/unit/query-generator/show-indexes-query.test.ts:213 | dialect.supports.schemas
test/unit/query-generator/drop-table-query.test.ts:74 | dialect.supports.schemas
test/unit/query-generator/insert-query.test.ts:132 | !dialect.supports.returnIntoValues
test/unit/query-generator/insert-query.test.ts:152 | !sequelize.dialect.supports.dataTypes.ARRAY
test/unit/query-generator/insert-query.test.ts:202 | dialect.supports.returnIntoValues
test/unit/query-generator/insert-query.test.ts:234 | dialect.supports.returnIntoValues
2. Tests that assert nothing on some dialects that run them
integration/model/create.test.js:1016"is possible to use functions as default values": only asserts on postgres and sqlite3. mysql, mariadb, mssql, db2, ibmi, oracle and snowflake run it but check nothing.integration/query-interface/describeTable.test.js:68: only asserts on postgres, mysql and mssql. mariadb and db2 return column comments as well, so they could probably be added.integration/query-interface/createTable.test.js:17: asserts nothing on sqlite3, db2, ibmi, oracle or snowflake.integration/query-interface/createTable.test.jsenum tests (105, 116, 129, 144, 167, 182): only postgres asserts anything. mysql and mariadb could check that the column type containsENUM(.
3. Assertions without an error class or message
These pass if the code fails for an unrelated reason. None is known to be wrong today.
- 131 bare
.to.be.rejected(including 3.eventually.be.rejected). 62 of them are inintegration/data-types/data-types.test.ts, 13 ininstance.validations.test.jsand 8 inhooks/bulkOperation.test.js. - 30 bare
.to.throw(): decorator tests inattribute.test.ts/table.test.ts, postgresrange-data-type.test.ts, BOOLEAN/STRINGvalidate,@sequelize/utilsparsers and predicates,sequelize.test.ts:98, and the clone helpers.
4. Smaller items
integration/dialects/postgres/query.test.js:407"supports alias minification with long model names in joins" queries empty tables, so it can't detect a wrong alias mapping, only a SQL error.integration/json.test.ts: thefindOne(...)+.to.existtests only have a matching row. Awherethat is ignored would still pass.integration/model/attributes/types.test.js:this.sqlAssertis a spy since meta: fix test assertions that cannot fail and lint for them #18520, but the bulkCreate and exclude tests still don't check that it was called.integration/model/findAll.test.js"should return raw data when raw is true" asserts onusers[0]inside the loop instead of onuser.unit/transaction.test.ts:85: the try block has no failure path, so the test would pass if snowflake stopped throwing.- The mssql package doesn't load chai-as-promised, so its tests can't use
rejectedWith. - Redundant checks that add noise but no coverage:
.not.to.be.nullright aftercreate()/findAll(): geography/geometry tests,searchPath.test.js,schema.test.js,sequelize.test.js:307,312,328,bulk-create.test.js:405, BLOB tests inmodel.test.js, postgresconnection-manager.test.ts:25.expect(error).to.be.instanceOf(X)right afterrejectedWith(X), kept in meta: fix test assertions that cannot fail and lint for them #18520 to keep its diff small.
include/findAll.test.jsandinclude/schema.test.jseach contain two tests with the same title.
🤖 Generated with Claude Code
Activity