Setting up a Test Environment TypeGraphQL

preview_player
Показать описание
Learn how to setup an environment to test your TypeGraphQL code.

Links from video:

----

----

----

----
Follow Me Online Here:

#benawad

----
#benawad
Рекомендации по теме
Комментарии
Автор

Well done. This is valuable content.

I especially appreciate how you follow good design principles by factoring small units of functionality out into their own files or modules and then importing that module at call sites.

kentbull
Автор

I had a Prisma 2 setup which uses the typical schema query language string and the resolvers passed to the GraphQLServer constructor. Had to use the makeExecutableSchema passing exactly those two values I mentioned earlier to this function to generate the schema, works wonderfully. Thank you!

RM-bgcd
Автор

For that jest hanging issue, it was redis not being disconnected on my end. You need to call redis.disconnect when you stop the server so the process can exit

MatthewLin
Автор

Great content. Thank you for sharing your knowledge.

jpbbr
Автор

You can grab Maybe directly from 'type-graphql'

jeromesnail
Автор

I am uaing tape as testrunner, but the whole setup process for the database really slipped the switch for me! Testing is so easy now.

MrProthall
Автор

Great video, Ben.

@BenAwad One question: is there a good way to run those tests in isolation _without_ hitting the database? E.g. an in-memory database mock that TypeORM is using instead of a real db? Something like mockgoose does?

abnormi
Автор

Hi Ben, thanks for the videos. For the build schema resolvers glob after googling a bit found that you can exclude directories so I created a __test__ folder inside modules so the glob would be `'/../modules/{, !(__test__)}/*.ts'`.

gaos
Автор

anyone got this problem:
schema: await createSchema();
}
return graphql({
schema,
source,
variableValues,

expected undefined to be a GraphQL schema

anismuhaimin
Автор

any chance you can do an updated version of this? or is there better software to use as of this date. I'm looking online and there seems to be a few options.

unixrebel
Автор

Getting this error:

console.log
{ errors:
[ GraphQLError {
message: 'Argument Validation Error',
locations: [ { line: 3, column: 3 } ],
path: [ 'register' ] } ],
data: null }

Any idea on how to debug?

mentansh
Автор

Instead of creating "interface Options" couldn't you "import GraphQLArgs" and use that as type for gCall parameter instead?

jasonjones
Автор

Great playlist sir.
But one doubt.
Is it possible to extend the classes in other files as it is done in Apollo .
type User {
name: String
}
in one file and extending this type in another file
extend type User{
email: String!
}
Is this possible using typegraphql??

kaousheik
Автор

Hey guys, does anyone get this error 'user" does not exist'' on running the test? How did you resolve it @benawad

ericmurithi
Автор

Register test is failing for me here:

describe("Register", () => {
> 29 | it("create user", async () => {
| ^

getting this error: "Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Timeout"

I can make the test pass if I remove the first "await" from "await sendEmail(email, await in the Register.ts file.

I copied and pasted both of your sendEmail and createConfirmationUrl functions from git, so they should be right.

Don't spend too much time on this, but maybe there is something obvious I am not seeing? I see sendEmail doesn't returns :Promise<void>. What are we awaiting?

johnmcneill
Автор

Where can I ask questions if my results differ because underlying libraries have changed, for example, formatValidationArgError is no longer available, so removing it might be causing all of my validations to fail when the test is run. If I remove all of them, the code works, but I get a warning in the console: No metadata found. There is more than once (sic) class-validator version installed probably. You need to flatten your dependencies.

richarddoust
Автор

How does the gCall function know that your server is running on localhost:4000?

gmanback
Автор

I'm getting the following test failure:
TypeError: Cannot read property 'close' of undefined

9 |
10 | afterAll(async () => {
> 11 | await conn.close()
| ^
12 | })
I've checked my code against your over and over. It's identical

stevereid
Автор

I've got this error and I could find out what's the problem:
```
{
errors: [
QueryFailedError: relation "user" does not exist
```

sinamaleki
Автор

Error: Cannot find connection default because its not defined in any orm configuration files

You have an idea how to solve this error,
I want to use my configuration ormconfig.json development and test of Airb&b, only accept the name : default

ivanrenedo