Closed davfive closed 4 years ago
Yes, this is expected behavior. app.getAppPath
will return the path to the 'entry point' script called by Electron. When you run electron-mocha, you're not executing your app, but electron-mocha so this is totally fine. To work around this I would suggest mocking out getAppPath
as this would probably be the right approach anyway, since this is a value that will vary greatly, especially when you package your app.
Thanks. That's what I ended up doing.
Hi, Version Info: electron-mocha: 8.2.2, mocha: 7.1.1, electron: 7.2.3
I added app.getAppPath() lookup to a helper file that now gets as part of my tests. Previously I was directly calling mocha, however with this I needed to start using electron-mocha (I think). When I run this from within my built electron app, it properly gives me the top-level of my src directory (package.json:
Essentially what happens is that if I run
npx electron-mocha 'src/**/*.spec.js'
Then when I have a standard js file (not part of a spec), I get this
I'm not sure if this is expected (albeit unfortunate) behavior or if I'm just missing something after reading the docs and scouring the source. I can't find out how to resolve this.
I've included a minimal setup that illustrates this. Just unzip the file and run
electron-mocha-wrong-getAppPath.zip