Skip to content

Commit

Permalink
fix(test): avoid component re-registration warning during unit tests (#…
Browse files Browse the repository at this point in the history
…2006)

I noticed we were getting warnings for re-registering a component due to #1981

This happens both in browser development environments (PR previews and locally) and also CLI based unit tests.

The unit test ones are noisier than the browser ones, seeing as the browser ones need to be looked for.

This PR only does the re-registration if we don't have a `process` meaning it doesn't happen in anything CLI based.

Signed-off-by: John Cowen <john.cowen@konghq.com>
  • Loading branch information
johncowen authored Jan 15, 2024
1 parent 88a680e commit bc60f8a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/services/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@ export const services: ServiceConfigurator<SupportedTokens> = (app) => [

[token('development.components'), {
service: () => {
return [
['KClipboardProvider', DebugKClipboardProvider],
]
// unit testing is likely to have process
// no matter which runner is used
// if we are unit testing don't decorate KClipboardProvider
return typeof process === 'undefined'
? [
['KClipboardProvider', DebugKClipboardProvider],
]
: []
},
labels: [
app.components,
Expand Down

0 comments on commit bc60f8a

Please sign in to comment.