Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ferrata/slonik-jest-memory-leak-demo
Repository to demonstrate a memory leak error when using Slonik and Jest
https://github.com/ferrata/slonik-jest-memory-leak-demo
Last synced: about 1 month ago
JSON representation
Repository to demonstrate a memory leak error when using Slonik and Jest
- Host: GitHub
- URL: https://github.com/ferrata/slonik-jest-memory-leak-demo
- Owner: ferrata
- Created: 2023-09-27T09:45:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-27T10:03:40.000Z (over 1 year ago)
- Last Synced: 2024-12-03T18:54:45.814Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Slonik/Jest Memory Leak Demo
This repository demonstrates a memory leak error message when running `jest` with the `--detectLeaks` flag. The error is reproducible when importing and using the `sql` tag from the `slonik` library in a test.
It's possible that this is a false positive, since the `jest` documentation states that the `--detectLeaks` flag is experimental.
## Steps to reproduce
```
npm install
npm test
```## Error message
```
> [email protected] test
> jest --detectLeaksconsole.log
{ sql: 'SELECT 1', values: [], type: 'SLONIK_TOKEN_FRAGMENT' }at Object. (test/dummy.test.ts:7:13)
FAIL test/dummy.test.ts
● Test suite failed to runEXPERIMENTAL FEATURE!
Your test suite is leaking memory. Please ensure all references are cleaned.There is a number of things that can leak memory:
- Async operations that have not finished (e.g. fs.readFile).
- Timers not properly mocked (e.g. setInterval, setTimeout).
- Keeping references to the global scope.at onResult (node_modules/@jest/core/build/TestScheduler.js:150:18)
at Array.map ()Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 2.272 s
Ran all test suites.
```