Skip to content

Commit 51bcdbf

Browse files
authored
Merge pull request #7 from morganney/develop
test: add Debug test
2 parents 47c9045 + faa9e48 commit 51bcdbf

File tree

7 files changed

+617
-622
lines changed

7 files changed

+617
-622
lines changed

.babelrc.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# webpack-strip-debug-loader
1+
# [`webpack-strip-debug-loader`](https://www.npmjs.com/package/webpack-strip-debug-loader)
22

3-
Removes [`debug`](https://www.npmjs.com/package/debug) usage from your source code during Webpack builds.
3+
![CI](https://github.com/morganney/webpack-strip-debug-loader/actions/workflows/ci.yml/badge.svg)
4+
5+
Removes [`debug`](https://www.npmjs.com/package/debug) usage from your source code during webpack builds.
46

57
## Usage
68

@@ -22,13 +24,13 @@ Just make simple debug statements.
2224
import { Debug } from 'webpack-strip-debug-loader'
2325

2426
// Or use require if you prefer that
25-
const { Debug } = require("webpack-strip-debug-loader")
27+
const { Debug } = require('webpack-strip-debug-loader')
2628

27-
const debug = Debug("feature")
29+
const debug = Debug('feature')
2830
const debugFoo = Debug('foo')
2931

3032
if (somethingOfInterestHappens) {
31-
debug("something happened")
33+
debug('something happened')
3234
}
3335

3436
if (foo) {
@@ -43,7 +45,7 @@ if (foo) {
4345

4446
### Stripping
4547

46-
To remove the logging and bundling of debug usage register this loader with Webpack.
48+
To remove the logging and bundling of debug usage register this loader with webpack.
4749

4850
```js
4951
module: {

__tests__/debug.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
import { jest } from '@jest/globals'
2-
31
import { Debug } from '../src/debug.js'
42

5-
jest.mock('debug')
6-
7-
let debug = null
8-
3+
/**
4+
* Testing that it wraps `debug` has to wait for better
5+
* support for mocks when using ESM
6+
* @see https://github.com/facebook/jest/pull/10976
7+
*/
98
describe('Debug', () => {
10-
beforeAll(async () => {
11-
;({ default: debug } = await import('debug'))
12-
})
13-
14-
it('wraps debug', () => {
15-
Debug('namespace')
16-
17-
expect(debug).toHaveBeenCalled()
9+
it('returns a function', () => {
10+
expect(Debug('test')).toEqual(expect.any(Function))
1811
})
1912
})

babel.config.cjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = function (api) {
2+
const env = process.env.NODE_ENV || 'development'
3+
const presets = [
4+
[
5+
'@babel/preset-env',
6+
{
7+
targets: {
8+
browsers: ['defaults', 'current node']
9+
},
10+
modules: 'commonjs'
11+
}
12+
]
13+
]
14+
15+
api.cache(() => env === 'development')
16+
17+
return {
18+
presets
19+
}
20+
}

jest.config.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ export default {
1010
* @see https://github.com/webpack/loader-runner/issues/61
1111
*/
1212
'!**/__tests__/loader.js',
13-
/**
14-
* Has to wait for better support for mocks when using ESM
15-
* @see https://github.com/facebook/jest/pull/10976
16-
*/
17-
'!**/__tests__/debug.js',
1813
'!**/__tests__/__fixtures__/*.js'
1914
],
2015
transform: {}

0 commit comments

Comments
 (0)