<NME> test.js
<BEF> 'use strict';
var path = require('path');
var helpers = require('yeoman-generator').test;
var assert = require('yeoman-assert');

describe('generator', function () {
	beforeEach(function (cb) {
		var deps = ['../app'];

		helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
			if (err) {
				cb(err);
				return;
			}

			this.generator = helpers.createGenerator('nm:app', deps, null, {skipInstall: true});
			cb();
		}.bind(this));
	});

	it('generates expected files', function (cb) {
		var expected = [
			'.editorconfig',
			'.gitattributes',
			'.gitignore',
			'.travis.yml',
			'index.js',
			'license',
			'package.json',
			'readme.md',
			'test.js'
		];

		helpers.mockPrompt(this.generator, {
			moduleName: 'test',
			githubUsername: 'test',
			website: 'test.com',
			cli: false
		});

		this.generator.run(function () {
			assert.file(expected);
			assert.noFile('cli.js');
			cb();
		});
	});

	it('CLI option', function (cb) {
		helpers.mockPrompt(this.generator, {
			moduleName: 'test',
			githubUsername: 'test',
			website: 'test.com',
			cli: true
		});

		this.generator.run(function () {
			assert.file('cli.js');
			assert.fileContent('package.json', /"bin":/);
			assert.fileContent('package.json', /"bin": "cli.js"/);
			assert.fileContent('package.json', /"meow"/);
			cb();
		});
	});
});
	assert.fileContent('package.json', /"bin": "cli.js"/);
	assert.fileContent('package.json', /"meow"/);
});

test.serial('nyc option', async () => {
	helpers.mockPrompt(generator, {
		moduleName: 'test',
		githubUsername: 'test',
		website: 'test.com',
		cli: false,
		nyc: true,
		codecov: false
	});

	await pify(generator.run.bind(generator))();

	assert.noFile('cli.js');
	assert.fileContent('.gitignore', /\.nyc_output/);
	assert.fileContent('.gitignore', /coverage/);
	assert.fileContent('package.json', /"xo && nyc ava"/);
	assert.fileContent('package.json', /"nyc": "/);
	assert.noFileContent('package.json', /"codecov":/);
	assert.noFileContent('package.json', /"lcov"/);
	assert.noFileContent('.github/workflows/main.yml', /codecov/);
});

test.serial('codecov option', async () => {
	helpers.mockPrompt(generator, {
		moduleName: 'test',
		githubUsername: 'test',
		website: 'test.com',
		cli: false,
		nyc: true,
		codecov: true
	});

	await pify(generator.run.bind(generator))();

	assert.noFile('cli.js');
	assert.fileContent('.gitignore', /\.nyc_output/);
	assert.fileContent('.gitignore', /coverage/);
	assert.fileContent('package.json', /"xo && nyc ava"/);
	assert.fileContent('package.json', /"nyc": "/);
	assert.fileContent('package.json', /"codecov":/);
	assert.fileContent('package.json', /"lcov"/);
	assert.fileContent('.github/workflows/main.yml', /codecov/);
});

test('parse scoped package names', t => {
	t.is(utils.slugifyPackageName('author/thing'), 'author-thing', 'slugify non-scoped packages');
	t.is(utils.slugifyPackageName('@author/thing'), '@author/thing', 'accept scoped packages');
	t.is(utils.slugifyPackageName('@author/hi/there'), 'author-hi-there', 'fall back to regular slugify if invalid scoped name');
});

test.serial('prompts for description', async () => {
	helpers.mockPrompt(generator, {
		moduleName: 'test',
		moduleDescription: 'foo',
		githubUsername: 'test',
		website: 'test.com',
		cli: false,
		nyc: true,
		codecov: true
	});

	await pify(generator.run.bind(generator))();

	assert.fileContent('package.json', /"description": "foo",/);
	assert.fileContent('readme.md', /> foo/);
});

test.serial('defaults to superb description', async () => {
	helpers.mockPrompt(generator, {
		moduleName: 'test',
		githubUsername: 'test',
		website: 'test.com',
		cli: false,
		nyc: true,
		codecov: true
	});

	await pify(generator.run.bind(generator))();

	assert.fileContent('package.json', /"description": "My .+ module",/);
	assert.fileContent('readme.md', /> My .+ module/);
});

<MSG> switch to AVA for testing the generator

<DFF> @@ -1,64 +1,53 @@
-'use strict';
-var path = require('path');
-var helpers = require('yeoman-generator').test;
-var assert = require('yeoman-assert');
+import path from 'path';
+import test from 'ava';
+import {test as helpers} from 'yeoman-generator';
+import assert from 'yeoman-assert';
+import pify from 'pify';
 
-describe('generator', function () {
-	beforeEach(function (cb) {
-		var deps = ['../app'];
+let generator;
 
-		helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
-			if (err) {
-				cb(err);
-				return;
-			}
+test.beforeEach(async t => {
+	await pify(helpers.testDirectory)(path.join(__dirname, 'temp'));
+	generator = helpers.createGenerator('nm:app', ['../app'], null, {skipInstall: true});
+});
 
-			this.generator = helpers.createGenerator('nm:app', deps, null, {skipInstall: true});
-			cb();
-		}.bind(this));
+test.serial('generates expected files', async t => {
+	helpers.mockPrompt(generator, {
+		moduleName: 'test',
+		githubUsername: 'test',
+		website: 'test.com',
+		cli: false
 	});
 
-	it('generates expected files', function (cb) {
-		var expected = [
-			'.editorconfig',
-			'.gitattributes',
-			'.gitignore',
-			'.travis.yml',
-			'index.js',
-			'license',
-			'package.json',
-			'readme.md',
-			'test.js'
-		];
-
-		helpers.mockPrompt(this.generator, {
-			moduleName: 'test',
-			githubUsername: 'test',
-			website: 'test.com',
-			cli: false
-		});
+	await pify(generator.run.bind(generator))();
+
+	assert.file([
+		'.editorconfig',
+		'.gitattributes',
+		'.gitignore',
+		'.travis.yml',
+		'index.js',
+		'license',
+		'package.json',
+		'readme.md',
+		'test.js'
+	]);
+
+	assert.noFile('cli.js');
+});
 
-		this.generator.run(function () {
-			assert.file(expected);
-			assert.noFile('cli.js');
-			cb();
-		});
+test.serial('CLI option', async t => {
+	helpers.mockPrompt(generator, {
+		moduleName: 'test',
+		githubUsername: 'test',
+		website: 'test.com',
+		cli: true
 	});
 
-	it('CLI option', function (cb) {
-		helpers.mockPrompt(this.generator, {
-			moduleName: 'test',
-			githubUsername: 'test',
-			website: 'test.com',
-			cli: true
-		});
+	await pify(generator.run.bind(generator))();
 
-		this.generator.run(function () {
-			assert.file('cli.js');
-			assert.fileContent('package.json', /"bin":/);
-			assert.fileContent('package.json', /"bin": "cli.js"/);
-			assert.fileContent('package.json', /"meow"/);
-			cb();
-		});
-	});
+	assert.file('cli.js');
+	assert.fileContent('package.json', /"bin":/);
+	assert.fileContent('package.json', /"bin": "cli.js"/);
+	assert.fileContent('package.json', /"meow"/);
 });

switch to AVA for testing the generator