Skip to content

Commit 6355c90

Browse files
run hydration test in separate running context
1 parent dcacb45 commit 6355c90

File tree

3 files changed

+36
-18
lines changed

3 files changed

+36
-18
lines changed

packages/devextreme-angular/gulpfile.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,23 @@ gulp.task('clean.generatedComponents', (done) => {
4545

4646
del.sync([
4747
`${outputFolderPath}/*/**`,
48-
...skipFromCleaningFiles.flatMap(keepPattern => {
49-
const pathParts = keepPattern.match(/[\*\/]$/) ? keepPattern.split('/') : [keepPattern];
48+
...skipFromCleaningFiles.flatMap((keepPattern) => {
49+
const pathParts = /[\*\/]$/.exec(keepPattern) ? keepPattern.split('/') : [keepPattern];
5050

5151
const patternsToKeep = pathParts.reduce((acc, pathPart) => {
52-
53-
if(pathPart) {
54-
acc.path += '/' + pathPart;
52+
if (pathPart) {
53+
acc.path += `/${pathPart}`;
5554
acc.patterns.push(`!${acc.path}`);
5655
}
5756

5857
return acc;
5958
}, {
6059
patterns: [],
61-
path: outputFolderPath.replace(/\/$/,'')
60+
path: outputFolderPath.replace(/\/$/, ''),
6261
}).patterns;
6362

6463
return patternsToKeep;
65-
})
64+
}),
6665
]);
6766

6867
done();
@@ -101,7 +100,7 @@ gulp.task('before-generate.preserve-component-files', (done) => {
101100
return () => gulp.src(src).pipe(gulp.dest(dest));
102101
});
103102

104-
gulp.parallel(...tasks)(done)
103+
gulp.parallel(...tasks)(done);
105104
});
106105

107106
gulp.task('generate.facades', gulp.series('generate.moduleFacades', (done) => {
@@ -213,16 +212,16 @@ gulp.task('npm.content', gulp.series(
213212

214213
return gulp.src([`${cmpConfig.outputPath}/**/collection.json`, ...npmConfig.content])
215214
.pipe(gulp.dest(npmConfig.distPath));
216-
}
215+
},
217216
));
218217

219218
gulp.task('npm.package-json', (cb) => {
220219
const pkgPath = path.join('.', buildConfig.npm.distPath, 'package.json');
221220
const pkg = require(`./${pkgPath}`);
222221
delete pkg.publishConfig;
223-
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2))
222+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
224223
cb();
225-
})
224+
});
226225

227226
gulp.task('npm.pack', gulp.series(
228227
'npm.content',
@@ -262,11 +261,9 @@ gulp.task('generate-component-names', (done) => {
262261
done();
263262
});
264263

265-
gulp.task('copy.dist.dx-angular', () => {
266-
return gulp
267-
.src(`${buildConfig.npm.distPath}/**/*`)
268-
.pipe(gulp.dest(path.join(buildConfig.components.testsPath, 'node_modules/devextreme-angular')));
269-
});
264+
gulp.task('copy.dist.dx-angular', () => gulp
265+
.src(`${buildConfig.npm.distPath}/**/*`)
266+
.pipe(gulp.dest(path.join(buildConfig.components.testsPath, 'node_modules/devextreme-angular'))));
270267

271268
gulp.task('build.tests', gulp.series('clean.tests', 'generate-component-names', 'copy.dist.dx-angular', () => {
272269
const config = buildConfig.components;
@@ -289,7 +286,7 @@ const getKarmaConfig = function (testsPath) {
289286
return karmaConfig.parseConfig(path.resolve('./karma.conf.js'), {
290287
files: [{ pattern: testsPath, watched: false }],
291288
preprocessors,
292-
}, {throwErrors: true});
289+
}, { throwErrors: true });
293290
};
294291

295292
gulp.task('test.components.client', gulp.series('build.tests', (done) => {
@@ -298,6 +295,8 @@ gulp.task('test.components.client', gulp.series('build.tests', (done) => {
298295

299296
gulp.task('test.components.server', gulp.series('build.tests', (done) => {
300297
new karmaServer(getKarmaConfig('./karma.server.test.shim.js'), done).start();
298+
}, (done) => {
299+
new karmaServer(getKarmaConfig('./karma.hydration.test.shim.js'), done).start();
301300
}));
302301

303302
gulp.task('test.components.client.debug', (done) => {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require('./karma.common.test.shim');
2+
3+
const testing = require('@angular/core/testing');
4+
const server = require('@angular/platform-server/testing');
5+
6+
const windowUtils = require('devextreme/core/utils/window');
7+
8+
const windowMock = {};
9+
windowMock.window = windowMock;
10+
windowUtils.setWindow(windowMock);
11+
12+
testing.TestBed.initTestEnvironment(
13+
server.ServerTestingModule,
14+
server.platformServerTesting(),
15+
);
16+
17+
const context = require.context('./tests/dist/server', true, /hydration\.spec\.js$/);
18+
context.keys().map(context);
19+
__karma__.start();

packages/devextreme-angular/karma.server.test.shim.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ testing.TestBed.initTestEnvironment(
1414
server.platformServerTesting(),
1515
);
1616

17-
const context = require.context('./tests/dist/server', true, /\.spec\.js$/);
17+
const context = require.context('./tests/dist/server', true, /^.\/(?!(hydration)\.spec\.js$).*\.spec\.js$/);
1818
context.keys().map(context);
1919
__karma__.start();

0 commit comments

Comments
 (0)