-
Notifications
You must be signed in to change notification settings - Fork 20
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
package under test not loaded? #5
Comments
i faced with the same problem, (mypackage-dir)/test-runner.js const fs = require('fs-plus');
const path = require('path');
const createRunner = require('atom-mocha-test-runner').createRunner;
const extraOptions = {
globalAtom: true
};
function optionalConfigurationFunction(mocha) {
let packageName = require('./package.json').name;
let packagesDir = atom.packages.getPackageDirPaths().find((path) => {
return path.endsWith('/dev/packages');
});
fs.makeTreeSync(packagesDir);
try {
fs.symlinkSync(__dirname, path.join(packagesDir, packageName), 'junction');
} catch (err) {
console.log(err);
}
}
module.exports = createRunner(extraOptions, optionalConfigurationFunction); |
Also stuck here 🤔 I'm not sure how https://github.com/atom/github gets around this. |
atom/github "gets around it" by never attempting to activate itself in its tests, the only package it activates is Steps to reproduce: Expected behavior: Actual behavior:
|
For the record, @ayapi's workaround works great. Perhaps a potential solution is simply to have |
Sorry it's taken me so long to get back to this issue. The atom-mocha-test-runner was designed to do way less automatic stuff when testing; the default Atom test runner mocks timers, creates Atom environments, and activates packages under test, which we wanted to avoid and make more explicit long term. That said, I definitely understand that this can be a surprising difference when migrating from the built-in runner, and the larger changes we wanted to make to the test process for Atom packages haven't been built yet, so I'm open to adding an option to activate the current project directory as an Atom package (assuming |
I started a new es6 atom package using jasmine, which contained code like:
And this worked as expected - the package was activated. However, similar code under the mocha runner doesn't work out the box.
Looking through the mocha runner code, I found that the config directory is set to a temporary directory by default, so the package isn't present in the atom environment. Is there a good way to have the package under test loaded?
What I did was to use
apm link
to ensure the package was installed in the global packages directory, and then addedWhich uses the global config directory - as used by the jasmine runner - so that the atom instance was configured using the global config. It's not ideal since the test environment is no longer clean, but it worked for local development.
The next hurdle was then getting the travis-ci build to run. It seems there was no way to have
apm link
run to have the package linked to the global atom config. I'm stuck here....and since it feels like I'm running uphill, against the grain, that might be a sign I'm on the wrong track and there's a simpler approach!Not sure if this is a bug, my misunderstanding or missing features, so just putting what I know here in case someone knows the way forward.
The text was updated successfully, but these errors were encountered: