Skip to content

Commit a73b2a4

Browse files
committed
feat: update e2e to module
1 parent 2037489 commit a73b2a4

9 files changed

Lines changed: 574 additions & 248 deletions

File tree

e2e/starter-e2e/jest.extend.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
module.exports = {
2+
moduleNameMapper: {
3+
'^(\\.{1,2}/.*)\\.js$': '$1',
4+
},
25
modulePathIgnorePatterns: ['./src/generators/'],
36
testEnvironment: 'node',
47
};

e2e/starter-e2e/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"type": "git",
88
"url": "https://github.com/AlexSergey/rockpack.git"
99
},
10+
"type": "module",
1011
"main": "index.js",
1112
"scripts": {
1213
"format": "npm run format:eslint",
@@ -18,7 +19,7 @@
1819
"@rockpack/tester": "8.0.0",
1920
"@types/kill-port": "2.0.3",
2021
"kill-port": "2.0.1",
21-
"puppeteer": "24.43.1",
22+
"puppeteer": "25.0.4",
2223
"rimraf": "6.1.3"
2324
},
2425
"devDependencies": {
@@ -41,6 +42,7 @@
4142
"serialize-javascript": "7.0.5",
4243
"source-map": "0.7.6",
4344
"stylelint-config-recommended-scss": "17.0.1",
44-
"stylelint-config-standard-scss": "17.0.0"
45+
"stylelint-config-standard-scss": "17.0.0",
46+
"tsx": "4.22.3"
4547
}
4648
}

e2e/starter-e2e/src/csr.server.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

e2e/starter-e2e/src/csr.server.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Koa from 'koa';
2+
import serve from 'koa-static';
3+
import { dirname, resolve } from 'node:path';
4+
import { fileURLToPath } from 'node:url';
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = dirname(__filename);
8+
9+
const app = new Koa();
10+
11+
const mode = process.argv[2];
12+
13+
app.use(serve(resolve(__dirname, `./generators/csr-${mode}-tests/dist`)));
14+
15+
app.listen(4000, () => {
16+
console.log(`Server is listening ${4000} port`);
17+
});

e2e/starter-e2e/src/generators.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { join } from 'node:path';
66
import puppeteer from 'puppeteer';
77
import { rimraf } from 'rimraf';
88

9-
import { exists } from './utils/fs';
10-
import { wait, waitForServer } from './utils/wait';
9+
import { exists } from './utils/fs.js';
10+
import { wait, waitForServer } from './utils/wait.js';
1111

1212
const starter = join(__dirname, '../../../packages/starter/lib/bin/index.mjs');
1313

@@ -247,7 +247,7 @@ describe('Generators tests', () => {
247247
const screenOriginalPth = `screenshots/original/csr-${tests ? 'with' : 'without'}-tests-build`;
248248
const screenNewPth = `screenshots/new/csr-${tests ? 'with' : 'without'}-tests-build`;
249249

250-
const serverProcess = spawn('node', ['./src/csr.server.js', tests ? 'with' : 'without'], {
250+
const serverProcess = spawn('tsx', ['./src/csr.server.js', tests ? 'with' : 'without'], {
251251
detached: true,
252252
});
253253

e2e/starter-e2e/src/utils/wait.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import http from 'node:http';
22

3-
export const wait = (delay = 1000) => {
3+
export const wait = (delay = 1000): Promise<void> => {
44
return new Promise((resolve) => setTimeout(resolve, delay));
55
};
66

0 commit comments

Comments
 (0)