Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Calling path.resolve from tests with "./" relative notation resolves it starting from project's root #40

Open
nicroto opened this issue Feb 5, 2014 · 1 comment

Comments

@nicroto
Copy link

nicroto commented Feb 5, 2014

app/
├── tests/
│ ├── data
│ ├──── data.json
│ ├── sample-test.js
└── Gruntfile.js
└── package.json

Gruntfile:
 grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    ...
    simplemocha: {
        all: { src: 'test/**/*-test.js' }
    },
    ...
 });

Issue:

  • calling path.resolve with "./data/data.json" from sample-test.js, results in path relative to the root dir of the project, e.g. could be "/Users/tsenkov/repos/app/data/data.json".

Expected:

  • "/Users/tsenkov/repos/app/tests/data/data.json"
@ChrisChares
Copy link

I've run into something that seems very similar when using cwd.

Gruntfile:
  grunt.initConfig({
  simplemocha: {
    target: {
      cwd: 'app1'
      src: 'test/**/*.js'
      ...
  • root/
    • app1/
      • test/
        • ...

this leads to the following error
Error: Cannot find module '/root/test/test.js'
It should be
`/root/app1/test/test.js'

thoughts?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants