@@ -13,7 +13,7 @@ import * as https from 'https';
13
13
import { from , throwError , timer } from 'rxjs' ;
14
14
import { concatMap , debounceTime , mergeMap , retryWhen , take } from 'rxjs/operators' ;
15
15
import { createArchitect , host } from '../../testing/utils' ;
16
- import { SSRDevServerBuilderOutput } from './index' ;
16
+ import { SSRDevServerBuilderOutput , log } from './index' ;
17
17
18
18
// todo check why it resolves to mjs
19
19
// [ERR_REQUIRE_ESM]: Must use import to load ES Module
@@ -168,6 +168,43 @@ describe('Serve SSR Builder', () => {
168
168
. toPromise ( ) ;
169
169
} ) ;
170
170
171
+ describe ( 'test logger' , ( ) => {
172
+ let resp = { stderr : '' , stdout : '' } ;
173
+ const logger = {
174
+ error : ( stderr : string ) => ( resp . stderr = stderr ) ,
175
+ info : ( stdout : string ) => ( resp . stdout = stdout ) ,
176
+ } ;
177
+
178
+ afterEach ( ( ) => ( resp = { stderr : '' , stdout : '' } ) ) ;
179
+
180
+ it ( 'should properly strip out new lines from output' , async ( ) => {
181
+ const data = { stderr : 'Error message\n' , stdout : 'Output message\n' } ;
182
+ log ( data , logger as any ) ;
183
+ expect ( resp . stderr ) . toBe ( 'Error message' ) ;
184
+ expect ( resp . stdout ) . toBe ( 'Output message' ) ;
185
+ } ) ;
186
+
187
+ it ( 'should only strip out the last new line' , async ( ) => {
188
+ const data = { stderr : 'Error message\n\n\n' , stdout : 'Output message\n\n' } ;
189
+ log ( data , logger as any ) ;
190
+ expect ( resp . stderr ) . toBe ( 'Error message\n\n' ) ;
191
+ expect ( resp . stdout ) . toBe ( 'Output message\n' ) ;
192
+ } ) ;
193
+
194
+ it ( 'work fine when nothing to strip out' , async ( ) => {
195
+ const data = { stderr : 'Typical error' , stdout : 'Typical output' } ;
196
+ log ( data , logger as any ) ;
197
+ expect ( resp . stderr ) . toBe ( 'Typical error' ) ;
198
+ expect ( resp . stdout ) . toBe ( 'Typical output' ) ;
199
+ } ) ;
200
+
201
+ it ( 'strip out webpack scheme' , async ( ) => {
202
+ const data = { stderr : 'webpack://foo' , stdout : '' } ;
203
+ log ( data , logger as any ) ;
204
+ expect ( resp . stderr ) . toBe ( '.foo' ) ;
205
+ } ) ;
206
+ } ) ;
207
+
171
208
it ( 'proxies requests based on the proxy configuration file provided in the option' , async ( ) => {
172
209
const proxyServer = http . createServer ( ( request , response ) => {
173
210
if ( request . url ?. endsWith ( '/test' ) ) {
0 commit comments