Skip to content

Commit 7d68a36

Browse files
committed
remove .only in packages/core/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts
1 parent 805d003 commit 7d68a36

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

jest-to-vitest.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## How to use
44

55
1. Run `npx vitest run --config vitest.one-by-one.config.ts PATH_TO_TEST_FILE`
6-
This is done as the main vitest config has a whitelist of tests to run and every new file that we migrate does not exist there.
6+
This is done as the main vitest config has a whitelist of tests to run and every new file that we migrate does not exist there.
77
2. Add the PATH_TO_TEST_FILE to the `migrated-suites.json` file
88

99
To run a specific suite with `jest`
@@ -23,3 +23,13 @@ npx jest --testPathPattern PATH_TO_TEST_FILE
2323
1. The file needs to include `import { MockInstance } from 'vitest';`
2424
2. Replace `let spy: jest.SpyInstance;` with `let spy: MockInstance;`
2525

26+
### vi.spyOn
27+
28+
1. When spying on `path`, needed to use this hack (doesn't work without shallow copying):
29+
30+
```js
31+
vi.mock('node:path', async () => {
32+
const actual = await vi.importActual('node:path');
33+
return { ...actual };
34+
});
35+
```

packages/core/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../
44
import { BaseResolver } from '../../../resolve';
55

66
describe('no-channel-trailing-slash', () => {
7-
it.only('should report on trailing slash in a channel path', async () => {
7+
it('should report on trailing slash in a channel path', async () => {
88
const document = parseYamlToDocument(
99
outdent`
1010
asyncapi: '3.0.0'

packages/core/src/rules/async3/no-channel-trailing-slash.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import type { Channel } from '../../typings/asyncapi3';
55
export const NoChannelTrailingSlash: Async3Rule = () => {
66
return {
77
Channel(channel: Channel, { report, location }: UserContext) {
8-
if ((channel.address as string).endsWith('/') && channel.address !== '/') {
8+
if (channel?.address?.endsWith('/') && channel?.address !== '/') {
99
report({
10-
message: `\`${channel.address}\` should not have a trailing slash.`,
10+
message: `\`${channel?.address}\` should not have a trailing slash.`,
1111
location: location.key(),
1212
});
1313
}

0 commit comments

Comments
 (0)