Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bvobart/gql-client-preset-swc-jest-issue
Minimum Reproducible Example for a code transformation issue with `@graphql-codegen/client-preset-swc-plugin`
https://github.com/bvobart/gql-client-preset-swc-jest-issue
Last synced: about 1 month ago
JSON representation
Minimum Reproducible Example for a code transformation issue with `@graphql-codegen/client-preset-swc-plugin`
- Host: GitHub
- URL: https://github.com/bvobart/gql-client-preset-swc-jest-issue
- Owner: bvobart
- License: mit
- Created: 2023-04-24T16:19:44.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-11T12:12:56.000Z (over 1 year ago)
- Last Synced: 2023-09-11T13:20:37.930Z (over 1 year ago)
- Language: TypeScript
- Size: 196 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE
Awesome Lists containing this project
README
# MRE for `@graphql-codegen/client-preset-swc-plugin` code transformation with Jest
## To reproduce the issue
```sh
# Install dependencies
yarn# Run the test
yarn jest issue.test.ts
```## Actual output
Jest will produce the following output:
```
FAIL tests/issue.test.ts
● Test suite failed to run× Expected ',', got ':'
╭─[/~censored~/gql-client-preset-swc-jest-issue/tests/Foo.ts:1:1]
1 │ export class Foo {
2 │ add(a: number, b: number): number {
· ─
3 │ return a + b
4 │ }
5 │ }
╰────Caused by:
Syntax Error3 | describe('something', () => {
4 | it('does something', () => {
> 5 | const foo = new Foo();
| ^
6 | expect(foo.add(1, 1)).toEqual(2);
7 | });
8 | });at Compiler.transformSync (node_modules/@swc/core/index.js:241:29)
at Object. (tests/issue.test.ts:5:14)Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.741 s
Ran all test suites matching /issue.test.ts/i.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```## Expected output
Jest is expected to run and pass the test, because `1 + 1 = 2`.
While the test is a TypeScript file, there is no TypeScript-specific syntax in it, so it can be interpreted as JS too.
The imported `Foo.ts` does contain TypeScript type annotations, but otherwise uses standard ECMAScript features (classes).