avajs / create-ava

Add AVA to your project
https://ava.li
MIT License
15 stars 6 forks source link

Also create minimal test.js file #14

Closed fregante closed 4 years ago

fregante commented 4 years ago

I kinda expected this package to also create a test file. Compared to running npm i ava -D it only adds "test": "ava". Almost not worth it 😄

const test = require('ava');
const m = require('.');

test('foo', t => {
    t.pass();
});

test('bar', async t => {
    const bar = Promise.resolve('bar');
    t.is(await bar, 'bar');
});

test('not undefined', t => {
    t.not(typeof m, 'undefined');
});

Also it should run ava right away, perhaps, but it might fail.

novemberborn commented 4 years ago

It's hard to know quite where to place that file, though.

I've opened https://github.com/avajs/create-ava/issues/15 — we could really do with a "wizard" style process where we ask the user some questions and then do a nice AVA setup.

fregante commented 4 years ago

It's hard to know quite where to place that file, though.

Why hard to know? It's the same position as package.json by default. If the user needs more code they can just move it to test/blah.js just like they can change the configuration.

I don't think the point of create-ava is to cover every AVA feature in a single command. Surely a wizard would be nice, but the creation of test.js would be a reasonable default just like "test": "ava" is

novemberborn commented 4 years ago

For a TypeScript project folks would expect a test.ts file, but probably in a src or source.

Others might prefer a module.test.js file and wrongly conclude that's not supported.

fregante commented 4 years ago

Sorry, that doesn’t make sense.

Typescript users still have to add configuration if they want direct support from AVA, would that make them “wrong conclude that typescript is not supported?”

I’m suggesting here to have smart defaults to save some time. As far as I know Sindre prefers no-config tools with smart defaults as well.

Either way for the end user it’s easier to move/rename this test.js than it is to create one and fill it with the boilerplate. I hope you agree with this