Skip to content

Instantly share code, notes, and snippets.

@imaman
Created August 13, 2020 10:55
Show Gist options
  • Save imaman/173da61485594af0098b81a972451ec0 to your computer and use it in GitHub Desktop.
Save imaman/173da61485594af0098b81a972451ec0 to your computer and use it in GitHub Desktop.
why I don't like .resolves
// with .resolves
expect(received).resolves.toBeDefined()
Received promise rejected instead of resolved
Rejected to value: [RequestError: Invalid authorization token provided: Bearer 0a933cd4bceffa68993ca34d58f31684d0923d31]
50 | })
51 |
> 52 | await expect(driver.runPr()).resolves.toBeDefined()
| ^
53 | })
54 |
55 | it('should run builds in parallel', async () => {
at expect (node_modules/expect/build/index.js:138:15)
at Object.<anonymous> (packages/orchestrator/test/it/parallel-build-scripts.inmemory.spec.ts:52:17)
// without .resolves
● parallel build scripts › task experiment off › with Lerna › when turned on › should run builds in a topological order
GotError: Invalid authorization token provided: Bearer 4f71e32ab63afcda273728325dabbe36023d1879
112 | ) => {
113 | if (req.headers['authorization'] !== `Bearer ${authToken}`) {
> 114 | cb(new Error(`Invalid authorization token provided: ${req.headers['authorization']}`), [403])
| ^
115 | }
116 | }
117 |
at onError (node_modules/got/dist/source/request-as-event-emitter.js:140:29)
at OverriddenClientRequest.<anonymous> (node_modules/got/dist/source/request-as-event-emitter.js:157:17)
at OverriddenClientRequest.origin.emit (node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
at node_modules/nock/lib/playback_interceptor.js:88:11
at ensureAuthorization (packages/testkits/git-server-testkit/src/github.ts:114:10)
at Interceptor.fullReplyFunction (packages/testkits/git-server-testkit/src/github.ts:166:7)
at internal/util.js:297:30
at start (node_modules/nock/lib/playback_interceptor.js:144:26)
at playbackInterceptor (node_modules/nock/lib/playback_interceptor.js:345:3)
at InterceptedRequestRouter.startPlayback (node_modules/nock/lib/intercepted_request_router.js:274:7)
at node_modules/nock/lib/intercepted_request_router.js:158:14
at InterceptedRequestRouter.handleWrite (node_modules/nock/lib/intercepted_request_router.js:128:9)
at OverriddenClientRequest.req.write (node_modules/nock/lib/intercepted_request_router.js:76:35)
at InterceptedRequestRouter.handleEnd (node_modules/nock/lib/intercepted_request_router.js:154:11)
at OverriddenClientRequest.req.end (node_modules/nock/lib/intercepted_request_router.js:77:33)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment