Skip to content

Multiple source roots - or something like classpath, like python_path, like include_path !!! #5893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iongion opened this issue Dec 2, 2015 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@iongion
Copy link

iongion commented Dec 2, 2015

I need to have the following structure:

  • build
    • debug
    • release
  • sources
    • clients
      • APIClient.ts
    • runtime
    • services
  • test
    • cases
      • clients
        • APIClientTest.ts
      • runtime
      • services
  • typings

My goal is that in the tests I want to be able to import the associated tested class without using /// reference.

This would work out of the box if the test would stay right next to the class, not in separate directories:

  • build
    • debug
    • release
  • sources
    • clients
      • APIClient.ts
      • APIClientTest.ts
    • runtime
    • services
  • typings

But it is extremly ugly and dirty and it gets even more so when these folders start growing(hundreds of classes, hundreds of tests ...)

My second attempt was to use a tsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "noImplicitAny": true,
        "noEmitOnError": true,
        "outDir": "./build/debug",
        "rootDir": "./",
        "sourceMap": false
    },
    "exclude": [
        "build",
        "node_modules"
    ]
}

But this creates weird folder structure inside build, understandable because it considers project root as source root which is not the same thing at all. Now, from what I've tried, the ideal situation would be to have multiple source directories that output in the same build dir. In this way, the tests would be able to avoid having to declare the horor that is /// reference.

I could use different tsconfig.json for sources and test directories, but then how do you specify the tests that references can be found additionally in another directory too.

What do you recommend, what can be done ?

@vladima
Copy link
Contributor

vladima commented Dec 2, 2015

if you are using modules then this proposal might be helpful

@mhegazy mhegazy added the Duplicate An existing issue was already created label Dec 2, 2015
@frankwallis
Copy link
Contributor

In every source directory create a directory called __tests__ where you keep your unit tests? This approach is used by test runners like jest.

You can then import the units under test using relative paths and it has the advantage that your tests are very visible and easy to find, but don't clutter up the source directories.

@mhegazy mhegazy closed this as completed Dec 7, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants