diff --git a/packages/hawtio/jest.config.ts b/packages/hawtio/jest.config.ts index d9d79a75..a38e5b72 100644 --- a/packages/hawtio/jest.config.ts +++ b/packages/hawtio/jest.config.ts @@ -15,6 +15,7 @@ const config: Config = { '\\.(css|less)$': '/src/__mocks__/styleMock.js', '@hawtiosrc/(.*)': '/src/$1', 'react-markdown': '/../../node_modules/react-markdown/react-markdown.min.js', + 'keycloak-js': path.resolve(__dirname, './src/__mocks__/keycloak.js'), 'monaco-editor': path.resolve(__dirname, './src/__mocks__/monacoEditor.js'), '@monaco-editor/react': path.resolve(__dirname, './src/__mocks__/monacoEditor.js'), '@patternfly/react-code-editor': path.resolve(__dirname, './src/__mocks__/codeEditorMock.js'), diff --git a/packages/hawtio/src/__mocks__/keycloak.js b/packages/hawtio/src/__mocks__/keycloak.js new file mode 100644 index 00000000..c3769a17 --- /dev/null +++ b/packages/hawtio/src/__mocks__/keycloak.js @@ -0,0 +1,3 @@ +module.exports = { + Keycloak: () => {}, +} diff --git a/packages/hawtio/src/plugins/auth/keycloak/keycloak-service.ts b/packages/hawtio/src/plugins/auth/keycloak/keycloak-service.ts index 32204a23..4bef8d76 100644 --- a/packages/hawtio/src/plugins/auth/keycloak/keycloak-service.ts +++ b/packages/hawtio/src/plugins/auth/keycloak/keycloak-service.ts @@ -237,7 +237,7 @@ class KeycloakService implements IKeycloakService { keycloak .updateToken(KEYCLOAK_TOKEN_MINIMUM_VALIDITY) - .then(refreshed => { + .then((refreshed: boolean) => { if (refreshed) { const token = keycloak.token if (token) { @@ -247,7 +247,7 @@ class KeycloakService implements IKeycloakService { log.debug('Token is still valid') } }) - .catch(reason => { + .catch((reason: Error) => { log.error("Couldn't update token:", reason) errorFn?.() }) diff --git a/packages/hawtio/tsconfig.json b/packages/hawtio/tsconfig.json index 1440b66c..63068776 100644 --- a/packages/hawtio/tsconfig.json +++ b/packages/hawtio/tsconfig.json @@ -16,7 +16,7 @@ "noImplicitThis": true, "noUncheckedIndexedAccess": true, "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true,