Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:SAP/spartacus into feature/CXSPA…
Browse files Browse the repository at this point in the history
…-8385
  • Loading branch information
Platonn committed Sep 20, 2024
2 parents 6f3e0d7 + ab4482f commit ff1976e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 384 deletions.
2 changes: 0 additions & 2 deletions core-libs/setup/ssr/logger/get-logger-inspect-options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// PRIVATE API

import { isDevMode } from '@angular/core';
import { InspectOptions } from 'node:util';

Expand Down
1 change: 1 addition & 0 deletions core-libs/setup/ssr/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

export * from './get-logger-inspect-options';
export * from './loggers/index';
export * from './services/index';
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,56 @@ describe('DefaultExpressServerLogger', () => {
`level9: [Object]`
);
});

it('should stringify Error instance passed as context', () => {
const debugSpy = jest
.spyOn(console, 'log')
.mockImplementation(() => {});

const error = new Error('test error');
logger.log('test', { error });

expect(debugSpy.mock.lastCall?.[0]).not.toContain(`"error": {}`);
expect(debugSpy.mock.lastCall?.[0]).toContain(
`"error": "Error: test error` // deliberate no closing double quote, because there goes the stacktrace
);
});

it('should not abbreviate Error details nested at 10 levels', () => {
const debugSpy = jest
.spyOn(console, 'log')
.mockImplementation(() => {});

const error = new Error('test error', {
cause: {
level2: {
level3: {
level4: {
level5: {
level6: {
level7: {
level8: {
level9: {
level10string: 'level10string',
},
},
},
},
},
},
},
},
},
});
logger.log('test', { error });

expect(debugSpy.mock.lastCall?.[0]).not.toContain(
`[cause]: { level2: { level3: [Object] } }`
);
expect(debugSpy.mock.lastCall?.[0]).toContain(
`[cause]: {\\n level2: {\\n level3: {\\n level4: {\\n level5: {\\n level6: {\\n level7: {\\n level8: { level9: { level10string: 'level10string' } }\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n}`
);
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import '@testing-library/cypress/add-commands';
import 'cypress-file-upload';
import './a11y-tab.commands';
import './cart.commands';
import './continuum.commands';
// TODO: Disabled until continuum is fixed for local env.
// import './continuum.commands';
import './cx-config.commands';
import './login.commands';
import './ng-select.commands';
Expand Down
Loading

0 comments on commit ff1976e

Please sign in to comment.