Skip to content
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

require() in config file does not hangle relative paths #304

Closed
vojtajina opened this issue Jan 15, 2013 · 9 comments
Closed

require() in config file does not hangle relative paths #304

vojtajina opened this issue Jan 15, 2013 · 9 comments

Comments

@vojtajina
Copy link
Contributor

Only abs paths work: require(__dirname + '/something.js');, because the require behaves as if it was run within config.js file, so you can load Testacular's source modules ;-)

@vojtajina
Copy link
Contributor Author

I'm really leaning towards changing the config file to be required as any other source file.

It will make the config file a bit more verbose, but will solve all these issues.

The syntax might be something like:

module.exports = function(config) {
  config.files = [...];
  config.reporters = ['dots];
};

Or

module.exports = {
  browsers: ['Safari', 'Chrome'],
  reporters: ['dots']
};

@dignifiedquire
Copy link
Member

👍 for the first run. This would make it easy for all people familiar withgrunt config.

@dignifiedquire
Copy link
Member

I've written up an alternative suggestion that is a much cleaner solution to this in my opinion. You can see it in this gist. In short the idea is to use YAML as config file format with some extras on top to keep all necessary options available.

@vojtajina
Copy link
Contributor Author

I feel very strongly about having the config file in JavaScript. It's powerful.

You can require other files, you can easily read env variables... and once we refactor for plugins, it allows for inlining plugins and many many other stuff.

Everyone who uses Testacular is familiar with JS.

@dignifiedquire
Copy link
Member

I see your points. Alright if JS then im all for something along the lines of

module.exports = function(testacular) {
  testacular.configure({
    browsers: ['Safari', 'Chrome'],
    reporters: ['dots']
  });
  // Maybe some plugin loading commands here on the testacular object
};

@vojtajina
Copy link
Contributor Author

@pavelgj Let's do this instead...

  • the config file is required as any other js file (therefore require and everything works just as expected)
  • config object is just a hash object passed to the user default config first (~/.karma.conf.js) then to project specific
  • we keep the whole object (you can add custom properties)

@pavelgj
Copy link
Contributor

pavelgj commented Apr 4, 2013

@vojtajina SGTM. +1 on doing it the right way. Did you already start working on it or do you want me to give it a shot?

@vojtajina
Copy link
Contributor Author

I have it pretty much done. I just need to decide which API is the best. I
will discuss it with Misko, feel free to stop by tomorrow...

On Wed, Apr 3, 2013 at 8:53 PM, Pavel Jbanov notifications@github.comwrote:

@vojtajina https://github.com/vojtajina SGTM. +1 on doing it the right
way. Did you already start working on it or do you want me to give it a
shot?


Reply to this email directly or view it on GitHubhttps://github.com//issues/304#issuecomment-15878703
.

@vojtajina
Copy link
Contributor Author

module.exports = function(karma) {
  karma.configure({
    basePath: '../',
    files: ['src/**/*.js']
  });

  // custom DSL
  karma.definePreprocessor('coffee_bare', {
    name: 'coffee',
    args: {'bare': false}
  });

  karma.defineLauncher('chrome', {
    name: 'Chrome',
    args: ['--flag']
  });
};

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

No branches or pull requests

3 participants