Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add broken parsing test #96

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/compile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,43 @@
`);
});


test('comments starting', () => {
const basePath = '/project';
const id = '__MODULE__';

const source = dedent`
import brol from 'x/y';

// see SpaceSelect
const spaceSelectQuery = graphql\`
query Test {
# This should be compiled
__typename
}
\`
`;

const result = compile(
path.join(basePath, id),
source,
{
module: 'esmodule',
isDevelopment: false,
codegenCommand: 'codegen',
},
);

expect(result.code).toEqual(dedent`

Check failure on line 211 in src/compile.test.ts

View workflow job for this annotation

GitHub Actions / Checking build and tests

src/compile.test.ts > comments starting

AssertionError: expected 'import brol from \'x/y\';\n\n// see S…' to deeply equal 'import brol from \'x/y\';\nimport gra…' - Expected + Received import brol from 'x/y'; - import graphql__f4ce3be5b8e81a99157cd3e378f936b6 from "./__generated__/Test.graphql"; - // This shouldn't be an issue - const spaceSelectQuery = graphql__f4ce3be5b8e81a99157cd3e378f936b6; + // see SpaceSelect + const spaceSelectQuery = graphql` + query Test { + # This should be compiled + __typename + } + ` ❯ src/compile.test.ts:211:23
import brol from 'x/y';
import graphql__f4ce3be5b8e81a99157cd3e378f936b6 from "./__generated__/Test.graphql";

// This shouldn't be an issue
const spaceSelectQuery = graphql__f4ce3be5b8e81a99157cd3e378f936b6;
`);
});


test('https://github.com/cometkim/vite-plugin-relay-lite/issues/53', () => {
const basePath = '/project';
const id = '__MODULE__';
Expand Down
Loading