File tree 5 files changed +80
-1
lines changed
docs/markdown/misc/settings
5 files changed +80
-1
lines changed Original file line number Diff line number Diff line change
1
+ # Miscellaneous Settings
2
+
3
+ ## Disabling BootstrapVue console warnings
4
+
5
+ BootstrapVue will warn (via ` console.warn ` ) when you try and use a depreated prop, or pass
6
+ an invalid value to certain props. These warnings are provided to help you ensure that your
7
+ application is using the correct props and values.
8
+
9
+ In some cases, you may want to disable these warnings (not recommended). You can do so by
10
+ setting the following process envinronment variable:
11
+
12
+ <!-- eslint-disable no-unused-vars -->
13
+
14
+ ``` js
15
+ process .env .BOOTSTRAP_VUE_NO_WARN = true
16
+ ```
17
+
18
+ By ignoring warnings, you may find that your project fails/breaks when using future releases
19
+ of bootstrapVue where deprecated props have been removed.
20
+
21
+ Warnings should be corrected before moving your project into production!
Original file line number Diff line number Diff line change
1
+ {
2
+ "title" : " Settings"
3
+ }
Original file line number Diff line number Diff line change 1
1
// Info about the current environment
2
2
3
+ // Constants
4
+
3
5
export const inBrowser = typeof document !== 'undefined' && typeof window !== 'undefined'
4
6
5
7
export const isServer = ! inBrowser
@@ -8,3 +10,7 @@ export const hasTouchSupport =
8
10
inBrowser && ( 'ontouchstart' in document . documentElement || navigator . maxTouchPoints > 0 )
9
11
10
12
export const hasPointerEvent = inBrowser && Boolean ( window . PointerEvent || window . MSPointerEvent )
13
+
14
+ // Getters
15
+
16
+ export const getNoWarn = ( ) => process && process . env && process . env . BOOTSTRAP_VUE_NO_WARN
Original file line number Diff line number Diff line change
1
+ import { getNoWarn } from './env'
2
+
1
3
/**
2
4
* Log a warning message to the console with bootstrap-vue formatting sugar.
3
5
* @param {string } message
4
6
*/
5
7
/* istanbul ignore next */
6
8
const warn = message => {
7
- console . warn ( `[BootstrapVue warn]: ${ message } ` )
9
+ if ( ! getNoWarn ( ) ) {
10
+ console . warn ( `[BootstrapVue warn]: ${ message } ` )
11
+ }
8
12
}
9
13
10
14
export default warn
Original file line number Diff line number Diff line change
1
+ import warn from './warn'
2
+
3
+ describe ( 'utils/warn' , ( ) => {
4
+ const dummyWarning = 'A Rush Of Blood To The Head'
5
+
6
+ let originalProcess
7
+
8
+ beforeAll ( ( ) => {
9
+ jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } )
10
+ originalProcess = global . process
11
+ } )
12
+
13
+ afterEach ( ( ) => {
14
+ console . warn . mockClear ( )
15
+ global . process = originalProcess
16
+ } )
17
+
18
+ describe ( 'with BOOTSTRAP_VUE_NO_WARN environment variable set' , ( ) => {
19
+ beforeEach ( ( ) => {
20
+ global . process = {
21
+ env : {
22
+ BOOTSTRAP_VUE_NO_WARN : true
23
+ }
24
+ }
25
+ } )
26
+
27
+ it ( 'does not call console.warn()' , ( ) => {
28
+ warn ( dummyWarning )
29
+
30
+ expect ( console . warn ) . not . toHaveBeenCalled ( )
31
+ } )
32
+ } )
33
+
34
+ describe ( 'without process object' , ( ) => {
35
+ beforeEach ( ( ) => {
36
+ global . process = null
37
+ } )
38
+
39
+ it ( 'calls console.warn()' , ( ) => {
40
+ warn ( dummyWarning )
41
+
42
+ expect ( console . warn ) . toHaveBeenCalledWith ( `[BootstrapVue warn]: ${ dummyWarning } ` )
43
+ } )
44
+ } )
45
+ } )
You can’t perform that action at this time.
0 commit comments