Add package to `project.toml` when needed only for testing?

The testing is fine with the workflow now, but here’s something I noticed when using Travis-CI:

If my .travis.yml file reads

language: julia

jobs:
  include:
    - stage: "Documentation"
      julia: 1.1
      os: linux
      script:
      - julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
      - julia --project=docs/ docs/make.jl
      after_success: skip

everything runs smoothly.

If I now add a test job to the .travis.yml file so that it reads like this,

language: julia
julia:
    - 1.1
jobs:
  include:
    - stage: "Documentation"
      julia: 1.1
      os: linux
      script:
      - julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
      - julia --project=docs/ docs/make.jl
      after_success: skip

then the test job will fail because the package Test was not found, i.e.

 Resolving package versions...
ERROR: LoadError: LoadError: ArgumentError: Package Test not found in current path:
- Run `import Pkg; Pkg.add("Test")` to install the Test package.

Inspecting the project.toml file afterwards, I see that the [targets] entry is missing!

Any ideas?