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

migrate to vitest #238

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12,850 changes: 4,879 additions & 7,971 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@
"precommit": "lint-staged",
"prepare": "npm run build && husky",
"pretest": "eslint .",
"test": "c8 esmocha --forbid-only"
"test": "vitest run --coverage"
},
"config": {
"doc_path": "../yeoman-test-doc"
},
"dependencies": {
"@vitest/coverage-v8": "^2.0.5",
"@yeoman/adapter": "^1.5.0",
"inquirer": "^9.2.2",
"lodash-es": "^4.17.21",
Expand All @@ -55,9 +56,7 @@
"@types/lodash-es": "^4.17.12",
"@types/node": "^18.19.46",
"@yeoman/eslint": "0.2.0",
"c8": "^10.1.2",
"coveralls": "^3.1.1",
"esmocha": "^1.0.1",
"husky": "^9.1.5",
"jsdoc": "^4.0.2",
"lint-staged": "^15.2.9",
Expand Down
2 changes: 1 addition & 1 deletion src/run-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ export class RunContextBase<GeneratorType extends BaseGenerator = DefaultGenerat
.catch(error => {
if (this.listenerCount('end') === 0 && this.listenerCount('error') === 0) {
// When there is no listeners throw a unhandled rejection.
setImmediate(async function () {
setImmediate(async () => {
throw error;
});
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/run-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import { type AskedQuestions } from './adapter.js';

const isObject = object => typeof object === 'object' && object !== null && object !== undefined;

function convertArguments(arguments_) {
const convertArguments = arguments_ => {
if (arguments_.length > 1) {
return [[...arguments_]];
}

const [argument] = arguments_;
return Array.isArray(argument) ? argument : [argument];
}
};

/**
* Provides options for `RunResult`s.
Expand Down
18 changes: 9 additions & 9 deletions test/adapter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import assert from 'node:assert';
import { describe, expect, it } from 'esmocha';
import { describe, expect, it } from 'vitest';
import { TestAdapter } from '../src/adapter.js';

describe('TestAdapter', function () {
describe('#prompt()', function () {
it('allows pre-filled answers', async function () {
describe('TestAdapter', () => {
describe('#prompt()', () => {
it('allows pre-filled answers', async () => {
const adapter = new TestAdapter();
return adapter
.prompt([{ name: 'respuesta', message: 'foo', type: 'input', default: 'bar' }], {
respuesta: 'foo',
})
.then(function (answers) {
.then(answers => {
assert.equal(answers.respuesta, 'foo');
});
});
});
describe('#queue()', function () {
it('should execute the callback', async function () {
describe('#queue()', () => {
it('should execute the callback', async () => {
const adapter = new TestAdapter();
await expect(adapter.queue(() => 2)).resolves.toBe(2);
});
});
describe('#progress()', function () {
it('should execute the callback', async function () {
describe('#progress()', () => {
it('should execute the callback', async () => {
const adapter = new TestAdapter();
await expect(
adapter.progress(({ step }) => {
Expand Down
Loading
Loading