Skip to content

Commit 73fed39

Browse files
add nextjs to testing on CI
1 parent d3fca67 commit 73fed39

File tree

6 files changed

+57
-41
lines changed

6 files changed

+57
-41
lines changed

.github/workflows/applications.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
APPROACH:
20-
- nextjs
20+
- react
21+
- nextjs-ts
2122
NODE:
2223
- 18
2324
OS:

packages/devextreme-cli/src/utility/run-command.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,13 @@ module.exports = function(commandName, args = [], customConfig = {}) {
1919

2020
const proc = spawn(command, args, config);
2121

22-
const promise = new Promise((resolve, reject) => {
23-
proc.on('exit', (code) => code ? reject(code) : resolve());
24-
});
25-
26-
promise.kill = (signal = 'SIGTERM') => {
27-
return new Promise((resolve, reject) => {
28-
proc.kill(signal);
29-
resolve();
22+
return new Promise((resolve, reject) => {
23+
proc.on('exit', (code) => {
24+
code ? reject(code) : resolve({ proc });
3025
});
31-
};
3226

33-
return promise;
27+
if(config.detached) {
28+
resolve({ proc });
29+
}
30+
});
3431
};

packages/devextreme-cli/testing/app-template.test.shared.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ module.exports = (env, { port } = { port: '8080' }) => {
4747
await devServer.setTheme(theme);
4848
await devServer.build();
4949
await devServer.start();
50+
/* console.log('-----waiting----->');
51+
await waitOn({
52+
resources: [appUrl],
53+
timeout: 30000,
54+
interval: 100
55+
}); */
5056
} catch(e) {
5157
// NOTE jest@27 will fail test, but jest@26 - not
52-
console.log('----throw new Error------>', e);
5358
throw new Error(e);
5459
}
5560
});
@@ -157,7 +162,7 @@ module.exports = (env, { port } = { port: '8080' }) => {
157162
}
158163

159164
describe(`${viewportName}`, () => {
160-
it('Home view', async() => {
165+
fit('Home view', async() => {
161166
await openPage(appUrl, { timeout: 5000 });
162167
await page.reload([{
163168
waitUntil: {

packages/devextreme-cli/testing/constants.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ exports.viewports = {
1414
width: 1280,
1515
height: 1024,
1616
},
17-
small: {
17+
/* small: {
1818
width: 667,
1919
height: 375,
2020
isMobile: true,
@@ -26,18 +26,18 @@ exports.viewports = {
2626
height: 568,
2727
isMobile: true,
2828
hasTouch: true,
29-
}
29+
}*/
3030
};
3131

3232
exports.themes = {
3333
material: 'material.blue',
34-
generic: 'generic',
35-
fluent: 'fluent.blue'
34+
/* generic: 'generic',
35+
fluent: 'fluent.blue'*/
3636
};
3737

3838
exports.layouts = [
3939
'side-nav-outer-toolbar',
40-
'side-nav-inner-toolbar'
40+
/* 'side-nav-inner-toolbar'*/
4141
];
4242

4343
exports.swatchModes = {

packages/devextreme-cli/testing/dev-server.js

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,29 @@
11
const fs = require('fs');
22
const path = require('path');
33
const WebServer = require('./web-server');
4+
const NextJsServer = require('./nextjs-server');
45

5-
const webServer = new WebServer();
66
const runCommand = require('../src/utility/run-command');
77
const { themes, swatchModes, baseFontFamily } = require('./constants');
8-
let startedPromise = null;
98

109
module.exports = class DevServer {
10+
isNextJs() {
11+
return this.env.engine.indexOf('nextjs') === 0;
12+
}
13+
1114
constructor(env) {
1215
this.env = env;
16+
this.server = this.isNextJs()
17+
? new NextJsServer(this.env)
18+
: new WebServer();
1319
}
1420

1521
async start() {
16-
if(this.env.engine.indexOf('nextjs') === 0) {
17-
if(startedPromise) {
18-
startedPromise.kill();
19-
startedPromise = null;
20-
}
21-
startedPromise = runCommand('npm', ['run', 'start'], {
22-
cwd: this.env.appPath,
23-
// https://github.com/facebook/create-react-app/issues/3657
24-
env: Object.assign(process.env, { CI: false })
25-
});
26-
} else {
27-
await webServer.start(this.env.deployPath);
28-
}
22+
await this.server.start(this.env.deployPath);
2923
}
3024

3125
async stop() {
32-
if(this.env.engine.indexOf('nextjs') === 0) {
33-
if(startedPromise) {
34-
await startedPromise.kill();
35-
startedPromise = null;
36-
}
37-
} else {
38-
await webServer.stop();
39-
}
26+
await this.server.stop();
4027
}
4128

4229
async build() {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const runCommand = require('../src/utility/run-command');
2+
3+
module.exports = class NextJsServer {
4+
constructor(env) {
5+
this.proc = null;
6+
this.env = env;
7+
}
8+
9+
async start() {
10+
({ proc: this.proc } = await runCommand('npm', ['run', 'start'], {
11+
cwd: this.env.appPath,
12+
detached: true,
13+
// https://github.com/facebook/create-react-app/issues/3657
14+
env: Object.assign(process.env, { CI: false })
15+
}));
16+
17+
await new Promise(resolve => setTimeout(resolve, 5000));
18+
}
19+
20+
stop() {
21+
if(this.proc) {
22+
this.proc.kill('SIGTERM');
23+
}
24+
}
25+
};
26+

0 commit comments

Comments
 (0)