Skip to content

Commit 9f095b0

Browse files
committed
Order the headless test's lines by what causes them
web says it waits as soon as it is launched; api starts once the first .env read is done, which can land either side.
1 parent 1b6796c commit 9f095b0

1 file changed

Lines changed: 25 additions & 14 deletions

File tree

‎packages/stackctl/e2e/headless.e2e.spec.ts‎

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,31 @@ test('headless with every service: the lines in order; SIGINT quits with exit 0'
2222
await session.waitForOutput(/\[web\s*\] web listening on 21082/);
2323
await session.waitForOutput(/\[worker\s*\] worker listening on \d+/);
2424

25-
const order = positions(session.stdout, [
26-
/\[stackctl\] \[INFO\] mode development \(default\)/,
27-
/\[api\s*\] started/,
28-
/\[web\s*\] waiting for api\.\.\./,
29-
/\[api\s*\] api listening on 21081/,
30-
/\[web\s*\] api ready, starting\.\.\./,
31-
/\[web\s*\] started/,
32-
/\[web\s*\] web listening on 21082/,
33-
]);
34-
expect(
35-
order.every((at) => at >= 0),
36-
session.stdout,
37-
).toBe(true);
38-
expect(order).toEqual([...order].sort((a, b) => a - b));
25+
// Two chains, each in order. Between them nothing is: web says it waits as soon as it is launched,
26+
// while api is started once the session's first `.env` read is done, which can come either side.
27+
const chains = [
28+
[
29+
/\[stackctl\] \[INFO\] mode development \(default\)/,
30+
/\[api\s*\] started/,
31+
/\[api\s*\] api listening on 21081/,
32+
],
33+
[
34+
/\[stackctl\] \[INFO\] mode development \(default\)/,
35+
/\[web\s*\] waiting for api\.\.\./,
36+
/\[api\s*\] api listening on 21081/,
37+
/\[web\s*\] api ready, starting\.\.\./,
38+
/\[web\s*\] started/,
39+
/\[web\s*\] web listening on 21082/,
40+
],
41+
];
42+
for (const chain of chains) {
43+
const order = positions(session.stdout, chain);
44+
expect(
45+
order.every((at) => at >= 0),
46+
session.stdout,
47+
).toBe(true);
48+
expect(order).toEqual([...order].sort((a, b) => a - b));
49+
}
3950
expect(session.stdout).toMatch(/\[worker\s*\] started/);
4051

4152
session.child.kill('SIGINT');

0 commit comments

Comments
 (0)