Skip to content

Commit 0d789b7

Browse files
clydindgp1130
authored andcommitted
test: cleanup E2E test regular expressions
Several of the older E2E tests that use regular expression based checks have been cleaned up by using string include checks where possible. Several regular expressions have also been simplified where possible.
1 parent 909f844 commit 0d789b7

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

tests/legacy-cli/e2e/tests/commands/builder-not-found.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default async function () {
1818
'ng',
1919
['build'],
2020
new RegExp(
21-
`Node packages may not be installed\. Try installing with '${getActivePackageManager()} install'\.`,
21+
`Node packages may not be installed\\. Try installing with '${getActivePackageManager()} install'\\.`,
2222
),
2323
),
2424
);
@@ -35,7 +35,7 @@ export default async function () {
3535
'ng',
3636
['build'],
3737
new RegExp(
38-
`Node packages may not be installed\. Try installing with '${getActivePackageManager()} install'\.`,
38+
`Node packages may not be installed\\. Try installing with '${getActivePackageManager()} install'\\.`,
3939
),
4040
);
4141
} finally {

tests/legacy-cli/e2e/tests/generate/module/module-import.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,55 +13,47 @@ export default function () {
1313
.then(() => ng('generate', 'module', 'sub/deep'))
1414

1515
.then(() => ng('generate', 'module', 'test1', '--module', 'app.module.ts'))
16-
.then(() =>
17-
expectFileToMatch(modulePath, /import { Test1Module } from '.\/test1\/test1.module'/),
18-
)
19-
.then(() => expectFileToMatch(modulePath, /imports: \[(.|\s)*Test1Module(.|\s)*\]/m))
16+
.then(() => expectFileToMatch(modulePath, `import { Test1Module } from './test1/test1.module'`))
17+
.then(() => expectFileToMatch(modulePath, /imports: \[.*?Test1Module.*?\]/s))
2018

2119
.then(() => ng('generate', 'module', 'test2', '--module', 'app.module'))
22-
.then(() =>
23-
expectFileToMatch(modulePath, /import { Test2Module } from '.\/test2\/test2.module'/),
24-
)
25-
.then(() => expectFileToMatch(modulePath, /imports: \[(.|\s)*Test2Module(.|\s)*\]/m))
20+
.then(() => expectFileToMatch(modulePath, `import { Test2Module } from './test2/test2.module'`))
21+
.then(() => expectFileToMatch(modulePath, /imports: \[.*?Test2Module.*?\]/s))
2622

2723
.then(() => ng('generate', 'module', 'test3', '--module', 'app'))
28-
.then(() =>
29-
expectFileToMatch(modulePath, /import { Test3Module } from '.\/test3\/test3.module'/),
30-
)
31-
.then(() => expectFileToMatch(modulePath, /imports: \[(.|\s)*Test3Module(.|\s)*\]/m))
24+
.then(() => expectFileToMatch(modulePath, `import { Test3Module } from './test3/test3.module'`))
25+
.then(() => expectFileToMatch(modulePath, /imports: \[.*?Test3Module.*?\]/s))
3226

3327
.then(() => ng('generate', 'module', 'test4', '--routing', '--module', 'app'))
34-
.then(() => expectFileToMatch(modulePath, /imports: \[(.|\s)*Test4Module(.|\s)*\]/m))
28+
.then(() => expectFileToMatch(modulePath, /imports: \[.*?Test4Module.*?\]/s))
3529
.then(() =>
3630
expectFileToMatch(
3731
join('src', 'app', 'test4', 'test4.module.ts'),
38-
/import { Test4RoutingModule } from '.\/test4-routing.module'/,
32+
`import { Test4RoutingModule } from './test4-routing.module'`,
3933
),
4034
)
4135
.then(() =>
4236
expectFileToMatch(
4337
join('src', 'app', 'test4', 'test4.module.ts'),
44-
/imports: \[(.|\s)*Test4RoutingModule(.|\s)*\]/m,
38+
/imports: \[.*?Test4RoutingModule.*?\]/s,
4539
),
4640
)
4741

4842
.then(() => ng('generate', 'module', 'test5', '--module', 'sub'))
4943
.then(() =>
50-
expectFileToMatch(subModulePath, /import { Test5Module } from '..\/test5\/test5.module'/),
44+
expectFileToMatch(subModulePath, `import { Test5Module } from '../test5/test5.module'`),
5145
)
52-
.then(() => expectFileToMatch(subModulePath, /imports: \[(.|\s)*Test5Module(.|\s)*\]/m))
46+
.then(() => expectFileToMatch(subModulePath, /imports: \[.*?Test5Module.*?\]/s))
5347

5448
.then(() =>
5549
ng('generate', 'module', 'test6', '--module', join('sub', 'deep'))
5650
.then(() =>
5751
expectFileToMatch(
5852
deepSubModulePath,
59-
/import { Test6Module } from '..\/..\/test6\/test6.module'/,
53+
`import { Test6Module } from '../../test6/test6.module'`,
6054
),
6155
)
62-
.then(() =>
63-
expectFileToMatch(deepSubModulePath, /imports: \[(.|\s)*Test6Module(.|\s)*\]/m),
64-
),
56+
.then(() => expectFileToMatch(deepSubModulePath, /imports: \[.*?Test6Module.*?\]/s)),
6557
);
6658

6759
// E2E_DISABLE: temporarily disable pending investigation

0 commit comments

Comments
 (0)