nexus-prisma
nexus-prisma copied to clipboard
Test gentime settings system
What
- we currently have no coverage over the gentime settings system
- check that config file errors, static OR runtime, are gracefully handled
- check that files of correct name/place are read as expected
- check that changing the settings actually has the intended effect
Why
- lot of IO and state and logical branching around this, no obvious bugs here, but not obviously no bugs!
How
- some kind of e2e test, multiple
- we can reuse our TestProject class abstraction
The E2E tests seem to be failing. Once they are stable I can add E2E test for settings
They are passing https://github.com/prisma/nexus-prisma/runs/2614915354#step:9:65?
Is it a false positive?
PASS tests/e2e/e2e.test.ts (57.338 s)
● Console
console.log
e2e test project at: /tmp/93c4a663d24ae05e8b37555bdd46f2f6
at Object.<anonymous> (tests/e2e/e2e.test.ts:284:11)
console.log
e2e output:
{
runFirstBuild: Error: Command failed with exit code 2: npm run build
npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1621375462727-0.8140294797271534/node but npm is using /opt/hostedtoolcache/node/12.22.1/x64/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-05-18T22_04_56_184Z-debug.log
> [email protected] build /tmp/93c4a663d24ae05e8b37555bdd46f2f6
> tsc
src/schema.ts(4,10): error TS2305: Module '"nexus-prisma"' has no exported member 'Bar'.
src/schema.ts(4,15): error TS2305: Module '"nexus-prisma"' has no exported member 'Foo'.
src/schema.ts(4,20): error TS2305: Module '"nexus-prisma"' has no exported member 'SomeEnumA'.
src/schema.ts(33,9): error TS2339: Property 'json' does not exist on type 'ObjectDefinitionBlock<any>'.
src/schema.ts(34,9): error TS2339: Property 'dateTime' does not exist on type 'ObjectDefinitionBlock<any>'.
at makeError (/home/runner/work/nexus-prisma/nexus-prisma/node_modules/[4mexeca[24m/lib/error.js:59:11)
at Function.Object.<anonymous>.module.exports.sync (/home/runner/work/nexus-prisma/nexus-prisma/node_modules/[4mexeca[24m/index.js:186:17)
at Object.<anonymous>.module.exports.commandSync (/home/runner/work/nexus-prisma/nexus-prisma/node_modules/[4mexeca[24m/index.js:225:15)
at runTestProjectBuild (/home/runner/work/nexus-prisma/nexus-prisma/tests/e2e/e2e.test.ts:39:31)
at Object.<anonymous> (/home/runner/work/nexus-prisma/nexus-prisma/tests/e2e/e2e.test.ts:286:19)
at Object.asyncJestTest (/home/runner/work/nexus-prisma/nexus-prisma/node_modules/[4mjest-jasmine2[24m/build/jasmineAsyncInstall.js:106:37)
at /home/runner/work/nexus-prisma/nexus-prisma/node_modules/[4mjest-jasmine2[24m/build/queueRunner.js:45:12
at new Promise (<anonymous>)
at mapper (/home/runner/work/nexus-prisma/nexus-prisma/node_modules/[4mjest-jasmine2[24m/build/queueRunner.js:28:19)
at /home/runner/work/nexus-prisma/nexus-prisma/node_modules/[4mjest-jasmine2[24m/build/queueRunner.js:75:41 {
shortMessage: [32m'Command failed with exit code 2: npm run build'[39m,
command: [32m'npm run build'[39m,
exitCode: [33m2[39m,
signal: [90mundefined[39m,
signalDescription: [90mundefined[39m,
stdout: [32m'\n'[39m +
[32m'> [email protected] build /tmp/93c4a663d24ae05e8b37555bdd46f2f6\n'[39m +
[32m'> tsc\n'[39m +
[32m'\n'[39m +
[32m`src/schema.ts(4,10): error TS2305: Module '"nexus-prisma"' has no exported member 'Bar'.\n`[39m +
[32m`src/schema.ts(4,15): error TS2305: Module '"nexus-prisma"' has no exported member 'Foo'.\n`[39m +
[32m`src/schema.ts(4,20): error TS2305: Module '"nexus-prisma"' has no exported member 'SomeEnumA'.\n`[39m +
[32m"src/schema.ts(33,9): error TS2339: Property 'json' does not exist on type 'ObjectDefinitionBlock<any>'.\n"[39m +
[32m"src/schema.ts(34,9): error TS2339: Property 'dateTime' does not exist on type 'ObjectDefinitionBlock<any>'."[39m,
stderr: [32m'npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1621375462727-0.8140294797271534/node but npm is using /opt/hostedtoolcache/node/12.22.1/x64/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.\n'[39m +
[32m'npm ERR! code ELIFECYCLE\n'[39m +
[32m'npm ERR! errno 2\n'[39m +
[32m'npm ERR! [email protected] build: `tsc`\n'[39m +
[32m'npm ERR! Exit status 2\n'[39m +
[32m'npm ERR! \n'[39m +
[32m'npm ERR! Failed at the [email protected] build script.\n'[39m +
[32m'npm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n'[39m +
[32m'\n'[39m +
[32m'npm ERR! A complete log of this run can be found in:\n'[39m +
[32m'npm ERR! /home/runner/.npm/_logs/2021-05-18T22_04_56_184Z-debug.log'[39m,
failed: [33mtrue[39m,
timedOut: [33mfalse[39m,
isCanceled: [33mfalse[39m,
killed: [33mfalse[39m
},
runReflectPrisma: {
command: [32m'npm run reflect:prisma'[39m,
exitCode: [33m0[39m,
stdout: [32m'\n'[39m +
[32m'> [email protected] reflect:prisma /tmp/93c4a663d24ae05e8b37555bdd46f2f6\n'[39m +
[32m'> prisma generate\n'[39m +
[32m'\n'[39m +
[32m'Environment variables loaded from .env\n'[39m +
[32m'Prisma schema loaded from prisma/schema.prisma\n'[39m +
[32m'You can now start using Nexus Prisma in your code. Reference: https://pris.ly/d/nexus-prisma\n'[39m +
[32m'\n'[39m +
[32m'✔ Generated Prisma Client (2.22.1) to ./node_modules/@prisma/client in 187ms\n'[39m +
[32m'\n'[39m +
[32m'✔ Generated Nexus Prisma to ./.yalc/nexus-prisma/dist/runtime in 298ms\n'[39m +
[32m'You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client\n'[39m +
[32m'```\n'[39m +
[32m"import { PrismaClient } from '@prisma/client'\n"[39m +
[32m'const prisma = new PrismaClient()\n'[39m +
[32m'```'[39m,
stderr: [32m'npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1621375462727-0.8140294797271534/node but npm is using /opt/hostedtoolcache/node/12.22.1/x64/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.'[39m,
failed: [33mfalse[39m,
timedOut: [33mfalse[39m,
isCanceled: [33mfalse[39m,
killed: [33mfalse[39m
},
runReflectNexus: {
command: [32m'npm run reflect:nexus'[39m,
exitCode: [33m0[39m,
stdout: [32m'\n'[39m +
[32m'> [email protected] reflect:nexus /tmp/93c4a663d24ae05e8b37555bdd46f2f6\n'[39m +
[32m'> cross-env REFLECT=true ts-node --transpile-only src/schema\n'[39m +
[32m'\n'[39m +
[32m'Generated Artifacts:\n'[39m +
[32m' TypeScript Types ==> /tmp/93c4a663d24ae05e8b37555bdd46f2f6/src/typegen.ts\n'[39m +
[32m' GraphQL Schema ==> /tmp/93c4a663d24ae05e8b37555bdd46f2f6/schema.graphql'[39m,
stderr: [32m'npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1621375462727-0.8140294797271534/node but npm is using /opt/hostedtoolcache/node/12.22.1/x64/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.'[39m,
failed: [33mfalse[39m,
timedOut: [33mfalse[39m,
isCanceled: [33mfalse[39m,
killed: [33mfalse[39m
},
runSecondBuild: {
command: [32m'npm run build'[39m,
exitCode: [33m0[39m,
stdout: [32m'\n'[39m +
[32m'> [email protected] build /tmp/93c4a663d24ae05e8b37555bdd46f2f6\n'[39m +
[32m'> tsc\n'[39m,
stderr: [32m'npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1621375462727-0.8140294797271534/node but npm is using /opt/hostedtoolcache/node/12.22.1/x64/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.'[39m,
failed: [33mfalse[39m,
timedOut: [33mfalse[39m,
isCanceled: [33mfalse[39m,
killed: [33mfalse[39m
},
fileGraphqlSchema: [32m'### This file was generated by Nexus Schema\n'[39m +
[32m'### Do not make changes to this file directly\n'[39m +
[32m'\n'[39m +
[32m'\n'[39m +
[32m'type Bar {\n'[39m +
[32m' foo: Foo\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'"""\n'[39m +
[32m'A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.\n'[39m +
[32m'"""\n'[39m +
[32m'scalar DateTime\n'[39m +
[32m'\n'[39m +
[32m'type Foo {\n'[39m +
[32m' DateTimeManually: DateTime\n'[39m +
[32m' JsonManually: Json\n'[39m +
[32m' someDateTimeField: DateTime!\n'[39m +
[32m' someEnumA: SomeEnumA\n'[39m +
[32m' someJsonField: Json!\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'"""\n'[39m +
[32m'The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).\n'[39m +
[32m'"""\n'[39m +
[32m'scalar Json @specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")\n'[39m +
[32m'\n'[39m +
[32m'type Query {\n'[39m +
[32m' bars: [Bar]\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'enum SomeEnumA {\n'[39m +
[32m' alpha\n'[39m +
[32m' bravo\n'[39m +
[32m' charlie\n'[39m +
[32m'}\n'[39m,
fileTypegen: [32m'/**\n'[39m +
[32m' * This file was generated by Nexus Schema\n'[39m +
[32m' * Do not make changes to this file directly\n'[39m +
[32m' */\n'[39m +
[32m'\n'[39m +
[32m'import * as PrismaClient from ".prisma/client"\n'[39m +
[32m'import { core } from "nexus"\n'[39m +
[32m'declare global {\n'[39m +
[32m' interface NexusGenCustomInputMethods<TypeName extends string> {\n'[39m +
[32m' /**\n'[39m +
[32m' * A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.\n'[39m +
[32m' */\n'[39m +
[32m' dateTime<FieldName extends string>(fieldName: FieldName, opts?: core.CommonInputFieldConfig<TypeName, FieldName>): void // "DateTime";\n'[39m +
[32m' /**\n'[39m +
[32m' * The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).\n'[39m +
[32m' */\n'[39m +
[32m' json<FieldName extends string>(fieldName: FieldName, opts?: core.CommonInputFieldConfig<TypeName, FieldName>): void // "Json";\n'[39m +
[32m' }\n'[39m +
[32m'}\n'[39m +
[32m'declare global {\n'[39m +
[32m' interface NexusGenCustomOutputMethods<TypeName extends string> {\n'[39m +
[32m' /**\n'[39m +
[32m' * A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.\n'[39m +
[32m' */\n'[39m +
[32m' dateTime<FieldName extends string>(fieldName: FieldName, ...opts: core.ScalarOutSpread<TypeName, FieldName>): void // "DateTime";\n'[39m +
[32m' /**\n'[39m +
[32m' * The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).\n'[39m +
[32m' */\n'[39m +
[32m' json<FieldName extends string>(fieldName: FieldName, ...opts: core.ScalarOutSpread<TypeName, FieldName>): void // "Json";\n'[39m +
[32m' }\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'\n'[39m +
[32m'declare global {\n'[39m +
[32m' interface NexusGen extends NexusGenTypes {}\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenInputs {\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenEnums {\n'[39m +
[32m' SomeEnumA: PrismaClient.SomeEnumA\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenScalars {\n'[39m +
[32m' String: string\n'[39m +
[32m' Int: number\n'[39m +
[32m' Float: number\n'[39m +
[32m' Boolean: boolean\n'[39m +
[32m' ID: string\n'[39m +
[32m' DateTime: any\n'[39m +
[32m' Json: any\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenObjects {\n'[39m +
[32m' Bar: PrismaClient.Bar;\n'[39m +
[32m' Foo: PrismaClient.Foo;\n'[39m +
[32m' Query: {};\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenInterfaces {\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenUnions {\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export type NexusGenRootTypes = NexusGenObjects\n'[39m +
[32m'\n'[39m +
[32m'export type NexusGenAllTypes = NexusGenRootTypes & NexusGenScalars & NexusGenEnums\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenFieldTypes {\n'[39m +
[32m' Bar: { // field return type\n'[39m +
[32m" foo: NexusGenRootTypes['Foo'] | null; // Foo\n"[39m +
[32m' }\n'[39m +
[32m' Foo: { // field return type\n'[39m +
[32m" DateTimeManually: NexusGenScalars['DateTime'] | null; // DateTime\n"[39m +
[32m" JsonManually: NexusGenScalars['Json'] | null; // Json\n"[39m +
[32m" someDateTimeField: NexusGenScalars['DateTime']; // DateTime!\n"[39m +
[32m" someEnumA: NexusGenEnums['SomeEnumA'] | null; // SomeEnumA\n"[39m +
[32m" someJsonField: NexusGenScalars['Json']; // Json!\n"[39m +
[32m' }\n'[39m +
[32m' Query: { // field return type\n'[39m +
[32m" bars: Array<NexusGenRootTypes['Bar'] | null> | null; // [Bar]\n"[39m +
[32m' }\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenFieldTypeNames {\n'[39m +
[32m' Bar: { // field return type name\n'[39m +
[32m" foo: 'Foo'\n"[39m +
[32m' }\n'[39m +
[32m' Foo: { // field return type name\n'[39m +
[32m" DateTimeManually: 'DateTime'\n"[39m +
[32m" JsonManually: 'Json'\n"[39m +
[32m" someDateTimeField: 'DateTime'\n"[39m +
[32m" someEnumA: 'SomeEnumA'\n"[39m +
[32m" someJsonField: 'Json'\n"[39m +
[32m' }\n'[39m +
[32m' Query: { // field return type name\n'[39m +
[32m" bars: 'Bar'\n"[39m +
[32m' }\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenArgTypes {\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenAbstractTypeMembers {\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenTypeInterfaces {\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export type NexusGenObjectNames = keyof NexusGenObjects;\n'[39m +
[32m'\n'[39m +
[32m'export type NexusGenInputNames = never;\n'[39m +
[32m'\n'[39m +
[32m'export type NexusGenEnumNames = keyof NexusGenEnums;\n'[39m +
[32m'\n'[39m +
[32m'export type NexusGenInterfaceNames = never;\n'[39m +
[32m'\n'[39m +
[32m'export type NexusGenScalarNames = keyof NexusGenScalars;\n'[39m +
[32m'\n'[39m +
[32m'export type NexusGenUnionNames = never;\n'[39m +
[32m'\n'[39m +
[32m'export type NexusGenObjectsUsingAbstractStrategyIsTypeOf = never;\n'[39m +
[32m'\n'[39m +
[32m'export type NexusGenAbstractsUsingStrategyResolveType = never;\n'[39m +
[32m'\n'[39m +
[32m'export type NexusGenFeaturesConfig = {\n'[39m +
[32m' abstractTypeStrategies: {\n'[39m +
[32m' isTypeOf: false\n'[39m +
[32m' resolveType: true\n'[39m +
[32m' __typename: false\n'[39m +
[32m' }\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'export interface NexusGenTypes {\n'[39m +
[32m' context: any;\n'[39m +
[32m' inputTypes: NexusGenInputs;\n'[39m +
[32m' rootTypes: NexusGenRootTypes;\n'[39m +
[32m' inputTypeShapes: NexusGenInputs & NexusGenEnums & NexusGenScalars;\n'[39m +
[32m' argTypes: NexusGenArgTypes;\n'[39m +
[32m' fieldTypes: NexusGenFieldTypes;\n'[39m +
[32m' fieldTypeNames: NexusGenFieldTypeNames;\n'[39m +
[32m' allTypes: NexusGenAllTypes;\n'[39m +
[32m' typeInterfaces: NexusGenTypeInterfaces;\n'[39m +
[32m' objectNames: NexusGenObjectNames;\n'[39m +
[32m' inputNames: NexusGenInputNames;\n'[39m +
[32m' enumNames: NexusGenEnumNames;\n'[39m +
[32m' interfaceNames: NexusGenInterfaceNames;\n'[39m +
[32m' scalarNames: NexusGenScalarNames;\n'[39m +
[32m' unionNames: NexusGenUnionNames;\n'[39m +
[32m" allInputTypes: NexusGenTypes['inputNames'] | NexusGenTypes['enumNames'] | NexusGenTypes['scalarNames'];\n"[39m +
[32m" allOutputTypes: NexusGenTypes['objectNames'] | NexusGenTypes['enumNames'] | NexusGenTypes['unionNames'] | NexusGenTypes['interfaceNames'] | NexusGenTypes['scalarNames'];\n"[39m +
[32m" allNamedTypes: NexusGenTypes['allInputTypes'] | NexusGenTypes['allOutputTypes']\n"[39m +
[32m" abstractTypes: NexusGenTypes['interfaceNames'] | NexusGenTypes['unionNames'];\n"[39m +
[32m' abstractTypeMembers: NexusGenAbstractTypeMembers;\n'[39m +
[32m' objectsUsingAbstractStrategyIsTypeOf: NexusGenObjectsUsingAbstractStrategyIsTypeOf;\n'[39m +
[32m' abstractsUsingStrategyResolveType: NexusGenAbstractsUsingStrategyResolveType;\n'[39m +
[32m' features: NexusGenFeaturesConfig;\n'[39m +
[32m'}\n'[39m +
[32m'\n'[39m +
[32m'\n'[39m +
[32m'declare global {\n'[39m +
[32m' interface NexusGenPluginTypeConfig<TypeName extends string> {\n'[39m +
[32m' }\n'[39m +
[32m' interface NexusGenPluginFieldConfig<TypeName extends string, FieldName extends string> {\n'[39m +
[32m' }\n'[39m +
[32m' interface NexusGenPluginInputFieldConfig<TypeName extends string, FieldName extends string> {\n'[39m +
[32m' }\n'[39m +
[32m' interface NexusGenPluginSchemaConfig {\n'[39m +
[32m' }\n'[39m +
[32m' interface NexusGenPluginArgConfig {\n'[39m +
[32m' }\n'[39m +
[32m'}'[39m
}
at Object.<anonymous> (tests/e2e/e2e.test.ts:289:11)
No, it tests that the first build fails, then after reflection, passes. And it always logs because it's hard to debug when it fails without logs. So I just log all the time.
Thank you for explaining. I find it a little confusing but at least I know to ignore it now...