apollographql / apollographql/apollo-tooling

Jest tests fail without --runInBand

Open
#1,853 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

**Intended outcome:**

Tests on clean checkout pass.

**Actual outcome:**

Code generation tests fail.

```
FAIL packages/apollo/src/commands/client/__tests__/generate.test.ts
● Console

console.error packages/apollo-language-server/lib/utilities/debug.js:41
A config file failed to load at '/home/mick/Programming/current/apollo-tooling'. This is likely because this file is empty or malformed. For more information, please refer to: https://go.apollo.dev/t/config
at Object.loadConfig (/home/mick/Programming/current/apollo-tooling/packages/apollo-language-server/src/config/loadConfig.ts:92:18)
at Generate.createConfig (/home/mick/Programming/current/apollo-tooling/packages/apollo/src/Command.ts:61:24)
at Generate.init (/home/mick/Programming/current/apollo-tooling/packages/apollo/src/Command.ts:44:24)
at Generate._run (/home/mick/Programming/current/apollo-tooling/packages/apollo/node_modules/@oclif/command/lib/command.js:43:13)

● client:codegen › writes swift types from local schema in a graphql file

A config failed to load, so the command couldn't be run

66 | char: "c",
67 | description: "Path to your Apollo config file"
> 68 | }),
| ^
69 | header: flags.string({
70 | multiple: true,
71 | parse: header => {

at Object.error (../../node_modules/@oclif/errors/lib/index.js:22:17)
at Generate.error (node_modules/@oclif/command/lib/command.js:57:23)
at Generate.createConfig (src/Command.ts:68:18)
at Generate.init (src/Command.ts:44:24)
at Generate._run (node_modules/@oclif/command/lib/command.js:43:13)
at Config.runCommand (../../node_modules/@oclif/config/lib/config.js:151:9)
at Object.run (../../node_modules/@oclif/test/lib/command.js:13:13)
at Object.run (../../node_modules/fancy-test/lib/base.js:50:25)
```

From a bit of debugging, there's some weird behaviour in `packages/apollo/src/Command.ts` in `createConfig()`. Specifically, `resolve(flags.config)` is called and returns `.../apollo-tooling/my.config.js`, whereas `resolve(process.cwd(), flags.config)` returns something like `.../apollo-tooling/__tmp__qxf914/my.config.js`. Using `--runInBand` causes the test to pass.

**How to reproduce the issue:**

Run `npm test`.

**Versions**

Commit: 04bf8429ef4453498b4405c6b05a74bc3bcccd08

I'm running Debian Stretch, node v12.16.1.

Contributor guide

Open the contributing guide

Research direction

Run npm test, then focus on packages/apollo/src/Command.ts and createConfig(), using packages/apollo/src/commands/client/__tests__/generate.test.ts as the failing entry point. Compare the config path resolution during parallel and --runInBand runs; done means the code generation tests pass without --runInBand on a clean checkout.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.