Skip to content

Commit 5d7cf67

Browse files
committed
fix e2e
1 parent 1d7586b commit 5d7cf67

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

eslint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ module.exports = defineConfig([
4848
}
4949
],
5050

51-
quotes: ["warn", "double"],
5251
semi: ["error", "always"],
5352
"no-var": ["error"],
5453
"no-console": 0,

test/e2e/call/index.spec.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { ServiceBroker } from "moleculer";
22
import { describe, it, expect, beforeAll, afterAll } from "vitest";
33
import { execa } from "execa";
4-
import path from "node:path";
54

6-
const binPath = path.resolve(__dirname, "./bin/moleculer.js");
5+
const binPath = "./bin/moleculer.js";
76

87
describe("E2E: call command", () => {
98
const transporter = "NATS";
@@ -31,30 +30,23 @@ describe("E2E: call command", () => {
3130
});
3231

3332
await broker.start();
34-
35-
console.log((await execa`ls -al`).stdout);
36-
console.log((await execa`ls -al bin`).stdout);
3733
});
3834

3935
afterAll(async () => {
4036
await broker.stop();
4137
});
4238

4339
it("should call an action and return expected output with exitCode 0", async () => {
44-
const actionName = "greeter.welcome";
45-
const param = "--@name=John";
46-
const cmd = `node ${binPath} call --ns ${ns} -t ${transporter} ${actionName} ${param}`;
47-
const { stdout, stderr, exitCode } = await execa(cmd);
40+
const { stdout, stderr, exitCode } =
41+
await execa`node ${binPath} call --ns ${ns} -t ${transporter} greeter.welcome --@name=John`;
4842
expect(exitCode).toBe(0);
4943
expect(stdout).toBe('"Hello John!"');
5044
expect(stderr).toBe("");
5145
});
5246

5347
it("should call an action with meta and return expected output with exitCode 0", async () => {
54-
const actionName = "greeter.welcome";
55-
const param = "--@name=John --#greeting=Hi";
56-
const cmd = `node ${binPath} call --ns ${ns} -t ${transporter} ${actionName} ${param}`;
57-
const { stdout, stderr, exitCode } = await execa(cmd);
48+
const { stdout, stderr, exitCode } =
49+
await execa`node ${binPath} call --ns ${ns} -t ${transporter} greeter.welcome --@name=John --#greeting=Hi`;
5850
expect(exitCode).toBe(0);
5951
expect(stdout).toBe('"Hi John!"');
6052
expect(stderr).toBe("");

test/e2e/emit/index.spec.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { ServiceBroker } from "moleculer";
22
import { vi, describe, it, expect, beforeAll, afterAll, beforeEach } from "vitest";
33
import { execa } from "execa";
4-
import path from "node:path";
54

6-
const binPath = path.resolve(__dirname, "../../../bin/moleculer.js");
5+
const binPath = "./bin/moleculer.js";
76

87
describe.skip("E2E: call command", () => {
98
const transporter = "NATS";
@@ -38,8 +37,8 @@ describe.skip("E2E: call command", () => {
3837
});
3938

4039
it("should emit an event", async () => {
41-
const cmd = `node ${binPath} emit --ns ${ns} -t ${transporter} test.event --@name=John`;
42-
const { stdout, stderr, exitCode } = await execa(cmd);
40+
const { stdout, stderr, exitCode } =
41+
await execa`node ${binPath} emit --ns ${ns} -t ${transporter} test.event --@name=John`;
4342
expect(exitCode).toBe(0);
4443
expect(stdout).toBe("OK");
4544
expect(stderr).toBe("");
@@ -58,8 +57,8 @@ describe.skip("E2E: call command", () => {
5857
});
5958

6059
it("should broadcast an event", async () => {
61-
const cmd = `node ${binPath} emit --ns ${ns} -t ${transporter} --broadcast test.event --@name=Jane`;
62-
const { stdout, stderr, exitCode } = await execa(cmd);
60+
const { stdout, stderr, exitCode } =
61+
await execa`node ${binPath} emit --ns ${ns} -t ${transporter} --broadcast test.event --@name=Jane`;
6362
expect(exitCode).toBe(0);
6463
expect(stdout).toBe("OK");
6564
expect(stderr).toBe("");
@@ -77,8 +76,8 @@ describe.skip("E2E: call command", () => {
7776
});
7877

7978
it("should broadcast an event with group but not called the greeter handler", async () => {
80-
const cmd = `node ${binPath} emit --ns ${ns} -t ${transporter} --broadcast --group asd test.event --@name=Jane`;
81-
const { stdout, stderr, exitCode } = await execa(cmd);
79+
const { stdout, stderr, exitCode } =
80+
await execa`node ${binPath} emit --ns ${ns} -t ${transporter} --broadcast --group asd test.event --@name=Jane`;
8281
expect(exitCode).toBe(0);
8382
expect(stdout).toBe("OK");
8483
expect(stderr).toBe("");
@@ -87,8 +86,8 @@ describe.skip("E2E: call command", () => {
8786
});
8887

8988
it("should broadcast an event with group and called the greeter handler", async () => {
90-
const cmd = `node ${binPath} emit --ns ${ns} -t ${transporter} --broadcast --group greeter test.event --@name=Jane`;
91-
const { stdout, stderr, exitCode } = await execa(cmd);
89+
const { stdout, stderr, exitCode } =
90+
await execa`node ${binPath} emit --ns ${ns} -t ${transporter} --broadcast --group greeter test.event --@name=Jane`;
9291
expect(exitCode).toBe(0);
9392
expect(stdout).toBe("OK");
9493
expect(stderr).toBe("");

0 commit comments

Comments
 (0)