Giter VIP home page Giter VIP logo

Comments (4)

bendrucker avatar bendrucker commented on July 29, 2024

Nope, this is just the way requires work. They're always relative to the file in which they run.

from proxyquire.

epchris avatar epchris commented on July 29, 2024

@bendrucker I understand that the actual call to require is done in proxyquire, but why would it matter where proxyquire was originally required? The call to proxyquire('../../foo/bar') is in the actual test itself and so I hoped the path would be relative to the test. Thanks for taking the time to explain.

from proxyquire.

bendrucker avatar bendrucker commented on July 29, 2024

Think about this in plain Node terms — what you're basically doing is this:

// a.js
module.exports = require
// b.js
var getModuleViaA = require('./a')
getModuleViaA(/* ... */)

require is a special global that is localized to each module. You can pass it around, but it will always be bound to the module it was created for.

from proxyquire.

sohale avatar sohale commented on July 29, 2024

As a workaround, you can use module name that has a full absolute path specified, in your calls to proxyquire(...).

from proxyquire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.