-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: add esm e2e test * test: update esm test to work with commonjs nexus-prisma * fix: remove esm build * fix: remove require statements from exports section
- Loading branch information
1 parent
8a50ccc
commit 9c549b8
Showing
13 changed files
with
129 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
const filter = (filenames) => | ||
filenames.filter((filename) => | ||
['docs', 'tests/e2e/fixtures'].every((pattern) => filename.indexOf(pattern) === -1), | ||
) | ||
|
||
module.exports = { | ||
'*': 'prettier --ignore-unknown --check', | ||
'*.{ts,tsx}': (filenames) => [ | ||
`yarn eslint --ext .ts,.tsx --max-warnings 0 ${filenames.join(' ')}`, | ||
`yarn eslint --ext .ts,.tsx --max-warnings 0 ${filter(filenames).join(' ')}`, | ||
'yarn type:check --skipLibCheck', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`esm: esm project successfully imports nexus-prisma 1`] = ` | ||
"type Foo { | ||
id: ID! | ||
} | ||
type Query { | ||
foos: [Foo] | ||
}" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { konn, providers } from 'konn' | ||
import * as Path from 'path' | ||
import { stripEndingLines } from '../__helpers__/helpers' | ||
import { project } from '../__providers__/project' | ||
import { monitorAsyncMethod, run } from '../__providers__/run' | ||
|
||
const ctx = konn().useBeforeEach(providers.dir()).useBeforeEach(run()).useBeforeEach(project()).done() | ||
|
||
it( | ||
'esm: esm project successfully imports nexus-prisma', | ||
async () => { | ||
expect.assertions(1) | ||
await ctx.fixture.useAsync(Path.join(__dirname, 'fixtures/esm')) | ||
await ctx.runAsyncOrThrow( | ||
`${Path.join(process.cwd(), 'node_modules/.bin/yalc')} add ${ctx.thisPackageName}`, | ||
) | ||
await monitorAsyncMethod( | ||
() => | ||
ctx.runPackagerCommandAsyncOrThrow('install', '--legacy-peer-deps', { | ||
env: { PEER_DEPENDENCY_CHECK: 'false' }, | ||
}), | ||
{ retry: 3, timeout: 90 * 1000 }, | ||
) | ||
await ctx.runPackagerCommandAsyncOrThrow('run', 'prisma generate') | ||
const result = await ctx.runPackagerCommandAsyncOrThrow('run', '--silent dev', { | ||
env: { PEER_DEPENDENCY_CHECK: 'false' }, | ||
}) | ||
expect(stripEndingLines(result.stdout)).toMatchSnapshot() | ||
}, | ||
320 * 1000, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { printSchema } from 'graphql' | ||
import { makeSchema, objectType, queryType } from 'nexus' | ||
import NexusPrisma from './nexus-prisma.cjs' | ||
const { Foo } = NexusPrisma | ||
|
||
const schema = makeSchema({ | ||
types: [ | ||
objectType({ | ||
name: Foo.$name, | ||
definition(t) { | ||
t.field(Foo.id) | ||
}, | ||
}), | ||
queryType({ | ||
definition(t) { | ||
t.list.field('foos', { | ||
type: 'Foo', | ||
resolve(_, __, ctx) { | ||
return ctx.prisma.foo.findMany() | ||
}, | ||
}) | ||
}, | ||
}), | ||
], | ||
}) | ||
|
||
console.log(printSchema(schema)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('.nexus-prisma') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "nexus-prisma-fixture-esm", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"build": "npm run build:prisma", | ||
"build:prisma": "prisma generate", | ||
"dev": "tsc && ts-node --esm main.js" | ||
}, | ||
"devDependencies": { | ||
"@prisma/client": "__dynamic__", | ||
"graphql": "__dynamic__", | ||
"nexus": "__dynamic__", | ||
"prisma": "__dynamic__", | ||
"ts-node": "10.9.1", | ||
"typescript": "5.1.6" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
datasource db { | ||
provider = "sqlite" | ||
url = "file:./db.sqlite" | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
generator nexusPrisma { | ||
provider = "nexus-prisma" | ||
} | ||
|
||
model Foo { | ||
id String @id @default(cuid()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"module": "ES2015" | ||
}, | ||
"include": ["."] | ||
} |