Closed sivakar12 closed 6 years ago
It looks like many tests are creating the same user again and again. Because we throw an error here those tests are failing. Should we remove the created user after each test ends? Or is there a better way?
I think we should create different users, unless we explicitly are testing for duplicates.
Some extra context; Jest does set up and tear down an in memory Mongo DB between each test suite, so we'll only need to be aware of side effects within suites.
@sivakar12 could you please rebase against staging so we can merge this?
The rebasing messed up the tests. I had to write them again. I couldn't remember how it looked earlier. I had to add another mock user to make things easier. You may have to review the tests again
That's interesting node_modules/graphql-tools/dist/schemaGenerator.js
now logs
{ Error: You must provide a valid email
at createUser (/home/travis/build/freeCodeCamp/open-api/src/dataLayer/mongo/user.js:39:11)
at Object.<anonymous> (/home/travis/build/freeCodeCamp/open-api/node_modules/graphql-tools/src/schemaGenerator.ts:683:22)
at class_1.<anonymous> (/home/travis/build/freeCodeCamp/open-api/node_modules/graphql-tools/src/schemaGenerator.ts:781:42)
at step (/home/travis/build/freeCodeCamp/open-api/node_modules/graphql-tools/dist/schemaGenerator.js:51:23)
at Object.next (/home/travis/build/freeCodeCamp/open-api/node_modules/graphql-tools/dist/schemaGenerator.js:32:53)
at /home/travis/build/freeCodeCamp/open-api/node_modules/graphql-tools/dist/schemaGenerator.js:26:71
at new Promise (<anonymous>)
at Object.<anonymous>.__awaiter (/home/travis/build/freeCodeCamp/open-api/node_modules/graphql-tools/dist/schemaGenerator.js:22:12)
at /home/travis/build/freeCodeCamp/open-api/node_modules/graphql-tools/src/schemaGenerator.ts:781:13
at isAuthenticatedOnQuery (/home/travis/build/freeCodeCamp/open-api/src/graphql/resolvers/directives.js:24:32)
at field.resolve (/home/travis/build/freeCodeCamp/open-api/node_modules/graphql-tools/src/schemaGenerator.ts:780:18)
at resolveFieldValueOrError (/home/travis/build/freeCodeCamp/open-api/node_modules/graphql/execution/execute.js:531:18)
at resolveField (/home/travis/build/freeCodeCamp/open-api/node_modules/graphql/execution/execute.js:495:16)
at /home/travis/build/freeCodeCamp/open-api/node_modules/graphql/execution/execute.js:339:18
at /home/travis/build/freeCodeCamp/open-api/node_modules/graphql/jsutils/promiseReduce.js:25:10
at Array.reduce (<anonymous>)
originalMessage: 'You must provide a valid email',
message: 'Error in resolver Mutation.createUser\nYou must provide a valid email' }
Lets keep that out of scope of the issue.
Wasn't this always the case? It does not show when --silent flag is given in our local environment. But in the CI there is no silent so you can see it. I don't this has anything to do with this issue
Thanks for all that work @sivakar12 !
@sivakar12 re: "Wasn't this always the case", you are absolutely right.
ISSUES CLOSED: #148