sequelize / sequelize/sequelize

sequelize transactions dont work with jest testing framework

Open
#16,193 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
30.4k
Forks
4.3k
Avg merge
1d 6h
Merged PRs (30d)
68

Description

Issue Creation Checklist

  • I understand that my issue will be automatically closed if I don't fill in the requested information
  • I have read the contribution guidelines

Feature Description

Describe the feature you'd like to see implemented

starting a sequelize transaction fails at this line in jest tests because of a long outstanding issue with jest

by any chance could the usage of instanceof be removed in just the following file: https://github.com/sequelize/sequelize/blob/99c3530c49d286fd0045712307110cd4f7f52add/src/dialects/abstract/query-interface.js

i confirmed that manually removing all instanceof calls in my local sequelize lib downloaded to node_modules solved the issue

Describe why you would like this feature to be added to Sequelize

fixing this in jest seems to be a while away, so i don't see any other choices for near term solutions. i tried https://www.npmjs.com/package/jest-environment-node-single-context but it didn't work for this

Is this feature dialect-specific?
  • No. This feature is relevant to Sequelize as a whole.
  • Yes. This feature only applies to the following dialect(s): postgres (this is the only dialect i've tested with)
Would you be willing to resolve this issue by submitting a Pull Request?
  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I will need guidance.
  • No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in implementing my feature.

i can open a PR to remove the instanceof checks in the one affected file but i'd like to hear from you guys if this is a change you'd be willing to accept and/or if you'd be willing to accept a different type of input validation for the transaction in that file


Indicate your interest in the addition of this feature by adding the 👍 reaction. Comments such as "+1" will be removed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting src/dialects/abstract/query-interface.js around the linked transaction validation lines and reproduce the failure in a Jest test using PostgreSQL. Determine how the transaction input can be validated without the failing instanceof checks; done means starting a Sequelize transaction succeeds in Jest while invalid inputs remain handled correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, postgresql, typescript
Domain
backend, databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.