Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fluffynuts/debugger-is-attached
https://github.com/fluffynuts/debugger-is-attached
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/fluffynuts/debugger-is-attached
- Owner: fluffynuts
- License: bsd-3-clause
- Created: 2020-07-24T15:04:34.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-11-13T08:39:23.000Z (2 months ago)
- Last Synced: 2024-12-14T09:46:28.362Z (29 days ago)
- Language: JavaScript
- Size: 1.78 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
debugger-is-attached
---
![Test](https://github.com/fluffynuts/debugger-is-attached/workflows/Tests/badge.svg)![npm](https://img.shields.io/npm/v/debugger-is-attached)
## What?
Lets you know if a debugger is _actually_ attached
## Why?
Sometimes I need to modify execution due to a debugger being attached. The
most obvious use-case is for setting a longer test timeout when debugging
a test.## There are other packages which do this!
Sort of. Some other attempts have been to observe the command-line
parameters of the current process, which doesn't work when, eg, debugging
a test in WebStorm. Also, debuggers _can detach_.This solution is based on a [GitHub comment](
https://github.com/nodejs/node/issues/9617#issuecomment-260729689)
so you know it's the real deal!## Usage
```
describe(`some fixture`, () => {
beforeEach(async () => {
const
debugging = await debuggerIsAttached(),
timeout = debugging ? 300000 : 5000;
jest.setTimeout(timeout);
});
it(`should do the things`, async () => {
// Arrange
// Act
// Assert
});
})
```## Credits
- to the author of the original comment, [mscdex](https://github.com/mscdex)
- [newts](https://npmjs.com/package/newts) for bootstrapping this easily so I
could just "get it out the door"