arackaf / mongo-graphql-starter

Creates a fully functioning, performant, extensible GraphQL endpoint from a Mongo DB. Supports middleware, Mongo 4 transactions.
MIT License
423 stars 29 forks source link

Feature/creategqltests #64

Closed duncanhealy closed 4 years ago

duncanhealy commented 4 years ago

test.js created

.prettierc to match project settings

arackaf commented 4 years ago

Hey I'm seeing some problems here - a bunch of tests are failing with this new file created. I'm not sure why, yet, and unfortunately don't really have time to look into it.

duncanhealy commented 4 years ago

I'll have a look tomorrow, I forked branch to module alias feature, so fixes probably in this branch

duncanhealy commented 4 years ago
arackaf commented 4 years ago

Hey - your tests PR is merged. I reverted your change to the connection string for testProject9 - I have a special connection string I run for project 9 tests to make sure transactions work (just ignore any failures in TestProject9).

As far as this PR goes, it looks like there are errors in your generation of test.js (I renamed it to test-resolvers.js). I branched off of your PR branch, merged master in, and then I added some debugging to show the error that's generated with test-resolvers.js.

The branch is feature/integrate-gql-pr - just pull that down, get everything fixed, and open a new PR off of that.

If you run the tests you should see the errors in the resolver test generation - something like this:

   ERROR GENERATING RESOLVER TESTS TypeError: Converting circular structure to JSON
      --> starting at object with constructor 'Object'
      |     property 'cachedMainAuthor' -> object with constructor 'Object'
      |     property 'type' -> object with constructor 'Object'
      |     ...
      |     property 'type' -> object with constructor 'Object'
      --- property 'fields' closes the circle
      at JSON.stringify (<anonymous>)
      at stringify (/Users/adam.rackis/Documents/git/mongo-graphql-starter/src/codeGen/createTestSchema.js:76:60)
      at Array.map (<anonymous>)
      at map (/Users/adam.rackis/Documents/git/mongo-graphql-starter/src/codeGen/createTestSchema.js:71:8)
      at /Users/adam.rackis/Documents/git/mongo-graphql-starter/src/createGraphqlSchema.js:129:18
      at create (/Users/adam.rackis/Documents/git/mongo-graphql-starter/test/testProject5/spinUp.js:12:3)
      at Object.<anonymous>.exports.default (/Users/adam.rackis/Documents/git/mongo-graphql-starter/test/testProject5/spinUp.js:25:3)
      at Object.<anonymous> (/Users/adam.rackis/Documents/git/mongo-graphql-starter/test/testProject5/addSubjectsArrayToNestedAuthors.test.js:9:71)
duncanhealy commented 4 years ago

Great :) the connection string is the reason I switched to use run-rs -> gives a replica set that can be used for all tests

Plan was to build more than the basic set of tests and put in a jest format I've fixed the circular ref and submitted pr #67

duncanhealy commented 4 years ago

think we can close this one

arackaf commented 4 years ago

whoa - run-rs looks great - I was wanting something like that when I wrote those test-project9 tests!

Will try to transition over to that at some point. In the meantime feel free to just ignore the project9 tests.

duncanhealy commented 4 years ago

I added the bit on run-rs to the Readme as it's far simpler to run than setting up a mongodb replicaset yourself :) it should be straight forward to do an automatic run of tests in a GitHub action when a PR is submitted

The module alias changes I made are not suitable for a PR yet, they would need to check package.json for module-alias, tsconfig, and check for symlinked folders etc