cli: trim away non-ascii in stream mock testing util
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -75,22 +75,22 @@ describe('backendPlugin factory', () => {
|
||||
'',
|
||||
'Creating backend plugin backstage-plugin-test-backend',
|
||||
'Checking Prerequisites:',
|
||||
'availability plugins/test-backend ✔',
|
||||
'creating temp dir ✔',
|
||||
'availability plugins/test-backend',
|
||||
'creating temp dir',
|
||||
'Executing Template:',
|
||||
'copying .eslintrc.js ✔',
|
||||
'templating README.md.hbs ✔',
|
||||
'templating package.json.hbs ✔',
|
||||
'copying tsconfig.json ✔',
|
||||
'copying index.ts ✔',
|
||||
'templating run.ts.hbs ✔',
|
||||
'copying setupTests.ts ✔',
|
||||
'copying router.test.ts ✔',
|
||||
'copying router.ts ✔',
|
||||
'templating standaloneServer.ts.hbs ✔',
|
||||
'copying .eslintrc.js',
|
||||
'templating README.md.hbs',
|
||||
'templating package.json.hbs',
|
||||
'copying tsconfig.json',
|
||||
'copying index.ts',
|
||||
'templating run.ts.hbs',
|
||||
'copying setupTests.ts',
|
||||
'copying router.test.ts',
|
||||
'copying router.ts',
|
||||
'templating standaloneServer.ts.hbs',
|
||||
'Installing:',
|
||||
'moving plugins/test-backend ✔',
|
||||
'backend adding dependency ✔',
|
||||
'moving plugins/test-backend',
|
||||
'backend adding dependency',
|
||||
]);
|
||||
|
||||
await expect(
|
||||
|
||||
@@ -88,14 +88,14 @@ some-package@^1.1.0:
|
||||
expect(modified).toBe(true);
|
||||
expect(output).toEqual([
|
||||
'Checking Prerequisites:',
|
||||
'availability /target ✔',
|
||||
'creating temp dir ✔',
|
||||
'availability /target',
|
||||
'creating temp dir',
|
||||
'Executing Template:',
|
||||
'templating package.json.hbs ✔',
|
||||
'copying not-templated.txt ✔',
|
||||
'templating templated.txt.hbs ✔',
|
||||
'templating package.json.hbs',
|
||||
'copying not-templated.txt',
|
||||
'templating templated.txt.hbs',
|
||||
'Installing:',
|
||||
'moving /target ✔',
|
||||
'moving /target',
|
||||
]);
|
||||
await expect(fs.readFile('/target/package.json', 'utf8')).resolves.toBe(`{
|
||||
"name": "my-testing-plugin",
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable no-control-regex */
|
||||
|
||||
import { WriteStream } from 'tty';
|
||||
import { resolve as resolvePath } from 'path';
|
||||
import { paths } from '../../../paths';
|
||||
@@ -59,10 +61,15 @@ export function createMockOutputStream() {
|
||||
cursorTo: () => {},
|
||||
clearLine: () => {},
|
||||
moveCursor: () => {},
|
||||
write: (msg: string) =>
|
||||
// Clean up colors and whitespace
|
||||
// eslint-disable-next-line no-control-regex
|
||||
output.push(msg.replace(/\x1B\[\d\dm/g, '').trim()),
|
||||
write: (msg: string) => {
|
||||
let clean = msg;
|
||||
// Remove terminal color escape sequences
|
||||
clean = clean.replace(/\x1B\[\d\dm/g, '');
|
||||
// Remove any non-ascii
|
||||
clean = clean.replace(/[^\x00-\x7F]+/g, '');
|
||||
clean = clean.trim();
|
||||
output.push(clean);
|
||||
},
|
||||
} as unknown as WriteStream & { fd: any },
|
||||
] as const;
|
||||
}
|
||||
|
||||
@@ -88,29 +88,29 @@ describe('frontendPlugin factory', () => {
|
||||
'',
|
||||
'Creating backend plugin backstage-plugin-test',
|
||||
'Checking Prerequisites:',
|
||||
'availability plugins/test ✔',
|
||||
'creating temp dir ✔',
|
||||
'availability plugins/test',
|
||||
'creating temp dir',
|
||||
'Executing Template:',
|
||||
'copying .eslintrc.js ✔',
|
||||
'templating README.md.hbs ✔',
|
||||
'templating package.json.hbs ✔',
|
||||
'copying tsconfig.json ✔',
|
||||
'templating index.tsx.hbs ✔',
|
||||
'templating index.ts.hbs ✔',
|
||||
'templating plugin.test.ts.hbs ✔',
|
||||
'templating plugin.ts.hbs ✔',
|
||||
'templating routes.ts.hbs ✔',
|
||||
'copying setupTests.ts ✔',
|
||||
'templating ExampleComponent.test.tsx.hbs ✔',
|
||||
'templating ExampleComponent.tsx.hbs ✔',
|
||||
'copying index.ts ✔',
|
||||
'templating ExampleFetchComponent.test.tsx.hbs ✔',
|
||||
'templating ExampleFetchComponent.tsx.hbs ✔',
|
||||
'copying index.ts ✔',
|
||||
'copying .eslintrc.js',
|
||||
'templating README.md.hbs',
|
||||
'templating package.json.hbs',
|
||||
'copying tsconfig.json',
|
||||
'templating index.tsx.hbs',
|
||||
'templating index.ts.hbs',
|
||||
'templating plugin.test.ts.hbs',
|
||||
'templating plugin.ts.hbs',
|
||||
'templating routes.ts.hbs',
|
||||
'copying setupTests.ts',
|
||||
'templating ExampleComponent.test.tsx.hbs',
|
||||
'templating ExampleComponent.tsx.hbs',
|
||||
'copying index.ts',
|
||||
'templating ExampleFetchComponent.test.tsx.hbs',
|
||||
'templating ExampleFetchComponent.tsx.hbs',
|
||||
'copying index.ts',
|
||||
'Installing:',
|
||||
'moving plugins/test ✔',
|
||||
'app adding dependency ✔',
|
||||
'app adding import ✔',
|
||||
'moving plugins/test',
|
||||
'app adding dependency',
|
||||
'app adding import',
|
||||
]);
|
||||
|
||||
await expect(
|
||||
|
||||
@@ -70,17 +70,17 @@ describe('pluginCommon factory', () => {
|
||||
'',
|
||||
'Creating backend plugin backstage-plugin-test-common',
|
||||
'Checking Prerequisites:',
|
||||
'availability plugins/test-common ✔',
|
||||
'creating temp dir ✔',
|
||||
'availability plugins/test-common',
|
||||
'creating temp dir',
|
||||
'Executing Template:',
|
||||
'copying .eslintrc.js ✔',
|
||||
'templating README.md.hbs ✔',
|
||||
'templating package.json.hbs ✔',
|
||||
'copying tsconfig.json ✔',
|
||||
'templating index.ts.hbs ✔',
|
||||
'copying setupTests.ts ✔',
|
||||
'copying .eslintrc.js',
|
||||
'templating README.md.hbs',
|
||||
'templating package.json.hbs',
|
||||
'copying tsconfig.json',
|
||||
'templating index.ts.hbs',
|
||||
'copying setupTests.ts',
|
||||
'Installing:',
|
||||
'moving plugins/test-common ✔',
|
||||
'moving plugins/test-common',
|
||||
]);
|
||||
|
||||
await expect(
|
||||
|
||||
@@ -70,20 +70,20 @@ describe('scaffolderModule factory', () => {
|
||||
'',
|
||||
'Creating module backstage-plugin-scaffolder-backend-module-test',
|
||||
'Checking Prerequisites:',
|
||||
'availability plugins/scaffolder-backend-module-test ✔',
|
||||
'creating temp dir ✔',
|
||||
'availability plugins/scaffolder-backend-module-test',
|
||||
'creating temp dir',
|
||||
'Executing Template:',
|
||||
'copying .eslintrc.js ✔',
|
||||
'templating README.md.hbs ✔',
|
||||
'templating package.json.hbs ✔',
|
||||
'copying tsconfig.json ✔',
|
||||
'templating index.ts.hbs ✔',
|
||||
'copying index.ts ✔',
|
||||
'copying example.test.ts ✔',
|
||||
'copying example.ts ✔',
|
||||
'copying index.ts ✔',
|
||||
'copying .eslintrc.js',
|
||||
'templating README.md.hbs',
|
||||
'templating package.json.hbs',
|
||||
'copying tsconfig.json',
|
||||
'templating index.ts.hbs',
|
||||
'copying index.ts',
|
||||
'copying example.test.ts',
|
||||
'copying example.ts',
|
||||
'copying index.ts',
|
||||
'Installing:',
|
||||
'moving plugins/scaffolder-backend-module-test ✔',
|
||||
'moving plugins/scaffolder-backend-module-test',
|
||||
]);
|
||||
|
||||
await expect(
|
||||
|
||||
Reference in New Issue
Block a user