Skip to content

Commit 9a98c19

Browse files
committed
jsdom + withoutInterceptors
1 parent 8fdbbbe commit 9a98c19

File tree

3 files changed

+41
-25
lines changed

3 files changed

+41
-25
lines changed

packages/laravel-echo/src/echo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ type GenericOptions<TBroadcaster extends keyof Broadcaster> = {
356356
host?: string | null;
357357
key?: string | null;
358358
namespace?: string | false;
359+
withoutInterceptors?: boolean;
359360

360361
[key: string]: any;
361362
};

packages/laravel-echo/tests/echo.test.ts

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,47 @@ import Echo from "../src/echo";
44

55
describe("Echo", () => {
66
test("it will not throw error for supported driver", () => {
7-
expect(() => new Echo({ broadcaster: "reverb" })).not.toThrow(
8-
"Broadcaster string reverb is not supported.",
9-
);
7+
expect(
8+
() =>
9+
new Echo({ broadcaster: "reverb", withoutInterceptors: true }),
10+
).not.toThrow("Broadcaster string reverb is not supported.");
1011

11-
expect(() => new Echo({ broadcaster: "pusher" })).not.toThrow(
12-
"Broadcaster string pusher is not supported.",
13-
);
12+
expect(
13+
() =>
14+
new Echo({ broadcaster: "pusher", withoutInterceptors: true }),
15+
).not.toThrow("Broadcaster string pusher is not supported.");
1416

15-
expect(() => new Echo({ broadcaster: "socket.io" })).not.toThrow(
16-
"Broadcaster string socket.io is not supported.",
17-
);
17+
expect(
18+
() =>
19+
new Echo({
20+
broadcaster: "socket.io",
21+
withoutInterceptors: true,
22+
}),
23+
).not.toThrow("Broadcaster string socket.io is not supported.");
1824

19-
expect(() => new Echo({ broadcaster: "null" })).not.toThrow(
20-
"Broadcaster string null is not supported.",
21-
);
22-
expect(() => new Echo({ broadcaster: NullConnector })).not.toThrow();
23-
24-
// eslint-disable-next-line
25-
// @ts-ignore
26-
// eslint-disable-next-line @typescript-eslint/no-empty-function
27-
expect(() => new Echo({ broadcaster: () => {} })).not.toThrow(
28-
"Broadcaster function is not supported.",
29-
);
25+
expect(
26+
() => new Echo({ broadcaster: "null", withoutInterceptors: true }),
27+
).not.toThrow("Broadcaster string null is not supported.");
28+
expect(
29+
() =>
30+
new Echo({
31+
broadcaster: NullConnector,
32+
withoutInterceptors: true,
33+
}),
34+
).not.toThrow();
35+
expect(
36+
() =>
37+
// @ts-ignore
38+
// eslint-disable-next-line @typescript-eslint/no-empty-function
39+
new Echo({ broadcaster: () => {}, withoutInterceptors: true }),
40+
).not.toThrow("Broadcaster function is not supported.");
3041
});
3142

3243
test("it will throw error for unsupported driver", () => {
33-
// eslint-disable-next-line
34-
// @ts-ignore
35-
expect(() => new Echo({ broadcaster: "foo" })).toThrow(
36-
"Broadcaster string foo is not supported.",
37-
);
44+
expect(
45+
// @ts-ignore
46+
// eslint-disable-next-line
47+
() => new Echo({ broadcaster: "foo", withoutInterceptors: true }),
48+
).toThrow("Broadcaster string foo is not supported.");
3849
});
3950
});

packages/laravel-echo/vite.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ const config: UserConfig = (() => {
5252
emptyOutDir: true,
5353
...common,
5454
},
55+
test: {
56+
globals: true,
57+
environment: "jsdom",
58+
},
5559
};
5660
})();
5761

0 commit comments

Comments
 (0)