-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fail when tests executed without cli #191
Conversation
var runner = new Runner(); | ||
|
||
// check if the test is being run without AVA cli | ||
var isForked = typeof process.send === 'function'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably clearer to just check if the file was executed directly: require.main === module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But index.js
is never required directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No matter if I use node test.js
or ava test.js
, require.main === module
is always false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, nvm. I'm sleepy...
b229dfb
to
8972428
Compare
var path = relative('.', process.argv[1]); | ||
|
||
log.write(); | ||
log.error('Test files must be run with the AVA CLI::\n\n $ ava ' + path + '\n'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double ::
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn it
8972428
to
956002e
Compare
var path = relative('.', process.argv[1]); | ||
|
||
log.write(); | ||
log.error('Test files must be run with the AVA CLI:\n\n $ ava ' + path + '\n'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and maybe add chalk.dim('$')
and chalk.cyan
to the command? just to be fancy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chalk.grey.dim('$') + ' ' + chalk.cyan('ava') + ' ' + path
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the full command:
chalk.dim('$') + ' ' + chalk.cyan('ava ' + path)
To indicate what they can copy-paste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. Just ava
in cyan looks better, but this is clearer.
956002e
to
41b4746
Compare
Fail when tests executed without cli
This PR fixes #179.
Here's the output: