summaryrefslogtreecommitdiff
path: root/packages/create-astro
diff options
context:
space:
mode:
Diffstat (limited to 'packages/create-astro')
-rw-r--r--packages/create-astro/package.json2
-rw-r--r--packages/create-astro/test/context.test.js49
-rw-r--r--packages/create-astro/test/dependencies.test.js34
-rw-r--r--packages/create-astro/test/fixtures/not-empty/package.json2
-rw-r--r--packages/create-astro/test/git.test.js12
-rw-r--r--packages/create-astro/test/intro.test.js14
-rw-r--r--packages/create-astro/test/next.test.js12
-rw-r--r--packages/create-astro/test/project-name.test.js69
-rw-r--r--packages/create-astro/test/template.test.js22
-rw-r--r--packages/create-astro/test/typescript.test.js48
-rw-r--r--packages/create-astro/test/utils.js1
-rw-r--r--packages/create-astro/test/verify.test.js18
12 files changed, 142 insertions, 141 deletions
diff --git a/packages/create-astro/package.json b/packages/create-astro/package.json
index b297afe1d..570b86ecd 100644
--- a/packages/create-astro/package.json
+++ b/packages/create-astro/package.json
@@ -22,7 +22,7 @@
"build": "astro-scripts build \"src/index.ts\" --bundle && tsc",
"build:ci": "astro-scripts build \"src/index.ts\" --bundle",
"dev": "astro-scripts dev \"src/**/*.ts\"",
- "test": "mocha --exit --timeout 20000 --parallel --ignore **/*.nodetest.js"
+ "test": "astro-scripts test \"test/**/*.test.js\""
},
"files": [
"dist",
diff --git a/packages/create-astro/test/context.test.js b/packages/create-astro/test/context.test.js
index 113417417..654733e6c 100644
--- a/packages/create-astro/test/context.test.js
+++ b/packages/create-astro/test/context.test.js
@@ -1,62 +1,73 @@
-import { expect } from 'chai';
-
+import assert from 'node:assert/strict';
+import { describe, it } from 'node:test';
import os from 'node:os';
import { getContext } from '../dist/index.js';
-
describe('context', () => {
it('no arguments', async () => {
const ctx = await getContext([]);
- expect(ctx.projectName).to.be.undefined;
- expect(ctx.template).to.be.undefined;
- expect(ctx.skipHouston).to.eq(os.platform() === 'win32');
- expect(ctx.dryRun).to.be.undefined;
+ assert.ok(!ctx.projectName);
+ assert.ok(!ctx.template);
+ assert.deepStrictEqual(ctx.skipHouston, os.platform() === 'win32');
+ assert.ok(!ctx.dryRun);
});
+
it('project name', async () => {
const ctx = await getContext(['foobar']);
- expect(ctx.projectName).to.eq('foobar');
+ assert.deepStrictEqual(ctx.projectName, 'foobar');
});
+
it('template', async () => {
const ctx = await getContext(['--template', 'minimal']);
- expect(ctx.template).to.eq('minimal');
+ assert.deepStrictEqual(ctx.template, 'minimal');
});
+
it('skip houston (explicit)', async () => {
const ctx = await getContext(['--skip-houston']);
- expect(ctx.skipHouston).to.eq(true);
+ assert.deepStrictEqual(ctx.skipHouston, true);
});
+
it('skip houston (yes)', async () => {
const ctx = await getContext(['-y']);
- expect(ctx.skipHouston).to.eq(true);
+ assert.deepStrictEqual(ctx.skipHouston, true);
});
+
it('skip houston (no)', async () => {
const ctx = await getContext(['-n']);
- expect(ctx.skipHouston).to.eq(true);
+ assert.deepStrictEqual(ctx.skipHouston, true);
});
+
it('skip houston (install)', async () => {
const ctx = await getContext(['--install']);
- expect(ctx.skipHouston).to.eq(true);
+ assert.deepStrictEqual(ctx.skipHouston, true);
});
+
it('dry run', async () => {
const ctx = await getContext(['--dry-run']);
- expect(ctx.dryRun).to.eq(true);
+ assert.deepStrictEqual(ctx.dryRun, true);
});
+
it('install', async () => {
const ctx = await getContext(['--install']);
- expect(ctx.install).to.eq(true);
+ assert.deepStrictEqual(ctx.install, true);
});
+
it('no install', async () => {
const ctx = await getContext(['--no-install']);
- expect(ctx.install).to.eq(false);
+ assert.deepStrictEqual(ctx.install, false);
});
+
it('git', async () => {
const ctx = await getContext(['--git']);
- expect(ctx.git).to.eq(true);
+ assert.deepStrictEqual(ctx.git, true);
});
+
it('no git', async () => {
const ctx = await getContext(['--no-git']);
- expect(ctx.git).to.eq(false);
+ assert.deepStrictEqual(ctx.git, false);
});
+
it('typescript', async () => {
const ctx = await getContext(['--typescript', 'strict']);
- expect(ctx.typescript).to.eq('strict');
+ assert.deepStrictEqual(ctx.typescript, 'strict');
});
});
diff --git a/packages/create-astro/test/dependencies.test.js b/packages/create-astro/test/dependencies.test.js
index 705cf8354..046e96591 100644
--- a/packages/create-astro/test/dependencies.test.js
+++ b/packages/create-astro/test/dependencies.test.js
@@ -1,8 +1,7 @@
-import { expect } from 'chai';
-
+import assert from 'node:assert/strict';
import { dependencies } from '../dist/index.js';
+import { describe, it } from 'node:test';
import { setup } from './utils.js';
-
describe('dependencies', () => {
const fixture = setup();
@@ -14,8 +13,10 @@ describe('dependencies', () => {
dryRun: true,
prompt: () => ({ deps: true }),
};
+
await dependencies(context);
- expect(fixture.hasMessage('Skipping dependency installation')).to.be.true;
+
+ assert.ok(fixture.hasMessage('Skipping dependency installation'));
});
it('prompt yes', async () => {
@@ -26,22 +27,27 @@ describe('dependencies', () => {
prompt: () => ({ deps: true }),
install: undefined,
};
+
await dependencies(context);
- expect(fixture.hasMessage('Skipping dependency installation')).to.be.true;
- expect(context.install).to.eq(true);
+
+ assert.ok(fixture.hasMessage('Skipping dependency installation'));
+ assert.equal(context.install, true);
});
it('prompt no', async () => {
const context = {
cwd: '',
+ install: true,
packageManager: 'npm',
dryRun: true,
prompt: () => ({ deps: false }),
install: undefined,
};
+
await dependencies(context);
- expect(fixture.hasMessage('Skipping dependency installation')).to.be.true;
- expect(context.install).to.eq(false);
+
+ assert.ok(fixture.hasMessage('Skipping dependency installation'));
+ assert.equal(context.install, false);
});
it('--install', async () => {
@@ -53,11 +59,11 @@ describe('dependencies', () => {
prompt: () => ({ deps: false }),
};
await dependencies(context);
- expect(fixture.hasMessage('Skipping dependency installation')).to.be.true;
- expect(context.install).to.eq(true);
+ assert.ok(fixture.hasMessage('Skipping dependency installation'));
+ assert.equal(context.install, true);
});
- it('--no-install', async () => {
+ it('--no-install ', async () => {
const context = {
cwd: '',
install: false,
@@ -65,8 +71,10 @@ describe('dependencies', () => {
dryRun: true,
prompt: () => ({ deps: false }),
};
+
await dependencies(context);
- expect(fixture.hasMessage('Skipping dependency installation')).to.be.true;
- expect(context.install).to.eq(false);
+
+ assert.ok(fixture.hasMessage('Skipping dependency installation'));
+ assert.equal(context.install, false);
});
});
diff --git a/packages/create-astro/test/fixtures/not-empty/package.json b/packages/create-astro/test/fixtures/not-empty/package.json
index dad4a5e5c..20127bbd3 100644
--- a/packages/create-astro/test/fixtures/not-empty/package.json
+++ b/packages/create-astro/test/fixtures/not-empty/package.json
@@ -6,4 +6,4 @@
"build": "astro check && astro build",
"preview": "astro preview"
}
-} \ No newline at end of file
+}
diff --git a/packages/create-astro/test/git.test.js b/packages/create-astro/test/git.test.js
index d05ad5bdc..f1c8eba0e 100644
--- a/packages/create-astro/test/git.test.js
+++ b/packages/create-astro/test/git.test.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import assert from 'node:assert/strict';
+import { describe, it, before, after } from 'node:test';
import { mkdir, writeFile } from 'node:fs/promises';
import { rmSync } from 'node:fs';
@@ -12,21 +13,20 @@ describe('git', () => {
const context = { cwd: '', dryRun: true, prompt: () => ({ git: false }) };
await git(context);
- expect(fixture.hasMessage('Skipping Git initialization')).to.be.true;
+ assert.ok(fixture.hasMessage('Skipping Git initialization'));
});
it('yes (--dry-run)', async () => {
const context = { cwd: '', dryRun: true, prompt: () => ({ git: true }) };
await git(context);
-
- expect(fixture.hasMessage('Skipping Git initialization')).to.be.true;
+ assert.ok(fixture.hasMessage('Skipping Git initialization'));
});
it('no (--dry-run)', async () => {
const context = { cwd: '', dryRun: true, prompt: () => ({ git: false }) };
await git(context);
- expect(fixture.hasMessage('Skipping Git initialization')).to.be.true;
+ assert.ok(fixture.hasMessage('Skipping Git initialization'));
});
});
@@ -48,7 +48,7 @@ describe('git initialized', () => {
};
await git(context);
- expect(fixture.hasMessage('Git has already been initialized')).to.be.true;
+ assert.ok(fixture.hasMessage('Git has already been initialized'));
});
after(() => {
diff --git a/packages/create-astro/test/intro.test.js b/packages/create-astro/test/intro.test.js
index 9014da457..d042dad7f 100644
--- a/packages/create-astro/test/intro.test.js
+++ b/packages/create-astro/test/intro.test.js
@@ -1,5 +1,5 @@
-import { expect } from 'chai';
-
+import assert from 'node:assert/strict';
+import { describe, it } from 'node:test';
import { intro } from '../dist/index.js';
import { setup } from './utils.js';
@@ -8,13 +8,13 @@ describe('intro', () => {
it('no arguments', async () => {
await intro({ skipHouston: false, version: '0.0.0', username: 'user' });
- expect(fixture.hasMessage('Houston:')).to.be.true;
- expect(fixture.hasMessage('Welcome to astro v0.0.0')).to.be.true;
+ assert.ok(fixture.hasMessage('Houston:'));
+ assert.ok(fixture.hasMessage('Welcome to astro v0.0.0'));
});
it('--skip-houston', async () => {
await intro({ skipHouston: true, version: '0.0.0', username: 'user' });
- expect(fixture.length()).to.eq(1);
- expect(fixture.hasMessage('Houston:')).to.be.false;
- expect(fixture.hasMessage('Launch sequence initiated')).to.be.true;
+ assert.equal(fixture.length(), 1);
+ assert.ok(!fixture.hasMessage('Houston:'));
+ assert.ok(fixture.hasMessage('Launch sequence initiated'));
});
});
diff --git a/packages/create-astro/test/next.test.js b/packages/create-astro/test/next.test.js
index 07de90d50..5b9b22b30 100644
--- a/packages/create-astro/test/next.test.js
+++ b/packages/create-astro/test/next.test.js
@@ -1,5 +1,5 @@
-import { expect } from 'chai';
-
+import assert from 'node:assert/strict';
+import { describe, it } from 'node:test';
import { next } from '../dist/index.js';
import { setup } from './utils.js';
@@ -8,13 +8,13 @@ describe('next steps', () => {
it('no arguments', async () => {
await next({ skipHouston: false, cwd: './it/fixtures/not-empty', packageManager: 'npm' });
- expect(fixture.hasMessage('Liftoff confirmed.')).to.be.true;
- expect(fixture.hasMessage('npm run dev')).to.be.true;
- expect(fixture.hasMessage('Good luck out there, astronaut!')).to.be.true;
+ assert.ok(fixture.hasMessage('Liftoff confirmed.'));
+ assert.ok(fixture.hasMessage('npm run dev'));
+ assert.ok(fixture.hasMessage('Good luck out there, astronaut!'));
});
it('--skip-houston', async () => {
await next({ skipHouston: true, cwd: './it/fixtures/not-empty', packageManager: 'npm' });
- expect(fixture.hasMessage('Good luck out there, astronaut!')).to.be.false;
+ assert.ok(!fixture.hasMessage('Good luck out there, astronaut!'));
});
});
diff --git a/packages/create-astro/test/project-name.test.js b/packages/create-astro/test/project-name.test.js
index 905f4a158..74196a35a 100644
--- a/packages/create-astro/test/project-name.test.js
+++ b/packages/create-astro/test/project-name.test.js
@@ -1,5 +1,5 @@
-import { expect } from 'chai';
-
+import assert from 'node:assert/strict';
+import { describe, it } from 'node:test';
import { projectName } from '../dist/index.js';
import { setup } from './utils.js';
@@ -9,25 +9,22 @@ describe('project name', async () => {
it('pass in name', async () => {
const context = { projectName: '', cwd: './foo/bar/baz', prompt: () => {} };
await projectName(context);
-
- expect(context.cwd).to.eq('./foo/bar/baz');
- expect(context.projectName).to.eq('baz');
+ assert.equal(context.cwd, './foo/bar/baz');
+ assert.equal(context.projectName, 'baz');
});
it('dot', async () => {
const context = { projectName: '', cwd: '.', prompt: () => ({ name: 'foobar' }) };
await projectName(context);
-
- expect(fixture.hasMessage('"." is not empty!')).to.be.true;
- expect(context.projectName).to.eq('foobar');
+ assert.ok(fixture.hasMessage('"." is not empty!'));
+ assert.equal(context.projectName, 'foobar');
});
it('dot slash', async () => {
const context = { projectName: '', cwd: './', prompt: () => ({ name: 'foobar' }) };
await projectName(context);
-
- expect(fixture.hasMessage('"./" is not empty!')).to.be.true;
- expect(context.projectName).to.eq('foobar');
+ assert.ok(fixture.hasMessage('"./" is not empty!'));
+ assert.equal(context.projectName, 'foobar');
});
it('empty', async () => {
@@ -37,9 +34,8 @@ describe('project name', async () => {
prompt: () => ({ name: 'foobar' }),
};
await projectName(context);
-
- expect(fixture.hasMessage('"./test/fixtures/empty" is not empty!')).to.be.false;
- expect(context.projectName).to.eq('empty');
+ assert.ok(!fixture.hasMessage('"./test/fixtures/empty" is not empty!'));
+ assert.equal(context.projectName, 'empty');
});
it('not empty', async () => {
@@ -49,59 +45,48 @@ describe('project name', async () => {
prompt: () => ({ name: 'foobar' }),
};
await projectName(context);
-
- expect(fixture.hasMessage('"./test/fixtures/not-empty" is not empty!')).to.be.true;
- expect(context.projectName).to.eq('foobar');
+ assert.ok(fixture.hasMessage('"./test/fixtures/not-empty" is not empty!'));
+ assert.equal(context.projectName, 'foobar');
});
it('basic', async () => {
const context = { projectName: '', cwd: '', prompt: () => ({ name: 'foobar' }) };
await projectName(context);
-
- expect(context.cwd).to.eq('foobar');
- expect(context.projectName).to.eq('foobar');
+ assert.equal(context.cwd, 'foobar');
+ assert.equal(context.projectName, 'foobar');
});
it('blank space', async () => {
- const context = { projectName: '', cwd: '', prompt: () => ({ name: 'foobar ' }) };
+ const context = { projectName: '', cwd: '', prompt: () => ({ name: 'foobar' }) };
await projectName(context);
-
- expect(context.cwd).to.eq('foobar');
- expect(context.projectName).to.eq('foobar');
+ assert.equal(context.cwd, 'foobar');
+ assert.equal(context.projectName, 'foobar');
});
it('normalize', async () => {
const context = { projectName: '', cwd: '', prompt: () => ({ name: 'Invalid Name' }) };
await projectName(context);
-
- expect(context.cwd).to.eq('Invalid Name');
- expect(context.projectName).to.eq('invalid-name');
+ assert.equal(context.cwd, 'Invalid Name');
+ assert.equal(context.projectName, 'invalid-name');
});
it('remove leading/trailing dashes', async () => {
const context = { projectName: '', cwd: '', prompt: () => ({ name: '(invalid)' }) };
await projectName(context);
-
- expect(context.projectName).to.eq('invalid');
+ assert.equal(context.projectName, 'invalid');
});
it('handles scoped packages', async () => {
const context = { projectName: '', cwd: '', prompt: () => ({ name: '@astro/site' }) };
await projectName(context);
-
- expect(context.cwd).to.eq('@astro/site');
- expect(context.projectName).to.eq('@astro/site');
+ assert.equal(context.cwd, '@astro/site');
+ assert.equal(context.projectName, '@astro/site');
});
it('--yes', async () => {
- const context = {
- projectName: '',
- cwd: './foo/bar/baz',
- yes: true,
- prompt: () => {},
- };
+ const context = { projectName: '', cwd: './foo/bar/baz', yes: true, prompt: () => {} };
await projectName(context);
- expect(context.projectName).to.eq('baz');
+ assert.equal(context.projectName, 'baz');
});
it('dry run with name', async () => {
@@ -112,7 +97,7 @@ describe('project name', async () => {
prompt: () => {},
};
await projectName(context);
- expect(context.projectName).to.eq('baz');
+ assert.equal(context.projectName, 'baz');
});
it('dry run with dot', async () => {
@@ -123,7 +108,7 @@ describe('project name', async () => {
prompt: () => ({ name: 'foobar' }),
};
await projectName(context);
- expect(context.projectName).to.eq('foobar');
+ assert.equal(context.projectName, 'foobar');
});
it('dry run with empty', async () => {
@@ -134,6 +119,6 @@ describe('project name', async () => {
prompt: () => ({ name: 'foobar' }),
};
await projectName(context);
- expect(context.projectName).to.eq('empty');
+ assert.equal(context.projectName, 'empty');
});
});
diff --git a/packages/create-astro/test/template.test.js b/packages/create-astro/test/template.test.js
index aef7e1944..821ac9c2e 100644
--- a/packages/create-astro/test/template.test.js
+++ b/packages/create-astro/test/template.test.js
@@ -1,43 +1,39 @@
-import { expect } from 'chai';
-
+import assert from 'node:assert/strict';
+import { describe, it } from 'node:test';
import { template } from '../dist/index.js';
import { setup } from './utils.js';
-describe('template', () => {
+describe('template', async () => {
const fixture = setup();
it('none', async () => {
const context = { template: '', cwd: '', dryRun: true, prompt: () => ({ template: 'blog' }) };
await template(context);
-
- expect(fixture.hasMessage('Skipping template copying')).to.be.true;
- expect(context.template).to.eq('blog');
+ assert.ok(fixture.hasMessage('Skipping template copying'));
+ assert.equal(context.template, 'blog');
});
it('minimal (--dry-run)', async () => {
const context = { template: 'minimal', cwd: '', dryRun: true, prompt: () => {} };
await template(context);
- expect(fixture.hasMessage('Using minimal as project template')).to.be.true;
+ assert.ok(fixture.hasMessage('Using minimal as project template'));
});
it('basics (--dry-run)', async () => {
const context = { template: 'basics', cwd: '', dryRun: true, prompt: () => {} };
await template(context);
-
- expect(fixture.hasMessage('Using basics as project template')).to.be.true;
+ assert.ok(fixture.hasMessage('Using basics as project template'));
});
it('blog (--dry-run)', async () => {
const context = { template: 'blog', cwd: '', dryRun: true, prompt: () => {} };
await template(context);
-
- expect(fixture.hasMessage('Using blog as project template')).to.be.true;
+ assert.ok(fixture.hasMessage('Using blog as project template'));
});
it('minimal (--yes)', async () => {
const context = { template: 'minimal', cwd: '', dryRun: true, yes: true, prompt: () => {} };
await template(context);
-
- expect(fixture.hasMessage('Using minimal as project template')).to.be.true;
+ assert.ok(fixture.hasMessage('Using minimal as project template'));
});
});
diff --git a/packages/create-astro/test/typescript.test.js b/packages/create-astro/test/typescript.test.js
index 461a3ed63..067957676 100644
--- a/packages/create-astro/test/typescript.test.js
+++ b/packages/create-astro/test/typescript.test.js
@@ -1,26 +1,26 @@
-import { expect } from 'chai';
-
+import assert from 'node:assert/strict';
+import { describe, it, beforeEach } from 'node:test';
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { typescript, setupTypeScript } from '../dist/index.js';
import { setup, resetFixtures } from './utils.js';
-describe('typescript', () => {
+describe('typescript', async () => {
const fixture = setup();
it('none', async () => {
const context = { cwd: '', dryRun: true, prompt: () => ({ ts: 'strict', useTs: true }) };
await typescript(context);
- expect(fixture.hasMessage('Skipping TypeScript setup')).to.be.true;
+ assert.ok(fixture.hasMessage('Skipping TypeScript setup'));
});
it('use false', async () => {
const context = { cwd: '', dryRun: true, prompt: () => ({ ts: 'strict', useTs: false }) };
await typescript(context);
- expect(fixture.hasMessage('No worries')).to.be.true;
+ assert.ok(fixture.hasMessage('No worries'));
});
it('strict', async () => {
@@ -31,9 +31,8 @@ describe('typescript', () => {
prompt: () => ({ ts: 'strict' }),
};
await typescript(context);
-
- expect(fixture.hasMessage('Using strict TypeScript configuration')).to.be.true;
- expect(fixture.hasMessage('Skipping TypeScript setup')).to.be.true;
+ assert.ok(fixture.hasMessage('Using strict TypeScript configuration'));
+ assert.ok(fixture.hasMessage('Skipping TypeScript setup'));
});
it('default', async () => {
@@ -44,9 +43,8 @@ describe('typescript', () => {
prompt: () => ({ ts: 'strict' }),
};
await typescript(context);
-
- expect(fixture.hasMessage('Using default TypeScript configuration')).to.be.true;
- expect(fixture.hasMessage('Skipping TypeScript setup')).to.be.true;
+ assert.ok(fixture.hasMessage('Using default TypeScript configuration'));
+ assert.ok(fixture.hasMessage('Skipping TypeScript setup'));
});
it('relaxed', async () => {
@@ -57,9 +55,8 @@ describe('typescript', () => {
prompt: () => ({ ts: 'strict' }),
};
await typescript(context);
-
- expect(fixture.hasMessage('Using relaxed TypeScript configuration')).to.be.true;
- expect(fixture.hasMessage('Skipping TypeScript setup')).to.be.true;
+ assert.ok(fixture.hasMessage('Using relaxed TypeScript configuration'));
+ assert.ok(fixture.hasMessage('Skipping TypeScript setup'));
});
it('other', async () => {
@@ -78,11 +75,11 @@ describe('typescript', () => {
} catch (e) {
err = e;
}
- expect(err).to.eq(1);
+ assert.equal(err, 1);
});
});
-describe('typescript: setup tsconfig', () => {
+describe('typescript: setup tsconfig', async () => {
beforeEach(() => resetFixtures());
it('none', async () => {
@@ -90,7 +87,7 @@ describe('typescript: setup tsconfig', () => {
const tsconfig = new URL('./tsconfig.json', root);
await setupTypeScript('strict', { cwd: fileURLToPath(root) });
- expect(JSON.parse(fs.readFileSync(tsconfig, { encoding: 'utf-8' }))).to.deep.eq({
+ assert.deepEqual(JSON.parse(fs.readFileSync(tsconfig, { encoding: 'utf-8' })), {
extends: 'astro/tsconfigs/strict',
});
});
@@ -99,13 +96,13 @@ describe('typescript: setup tsconfig', () => {
const root = new URL('./fixtures/not-empty/', import.meta.url);
const tsconfig = new URL('./tsconfig.json', root);
await setupTypeScript('strict', { cwd: fileURLToPath(root) });
- expect(JSON.parse(fs.readFileSync(tsconfig, { encoding: 'utf-8' }))).to.deep.eq({
+ assert.deepEqual(JSON.parse(fs.readFileSync(tsconfig, { encoding: 'utf-8' })), {
extends: 'astro/tsconfigs/strict',
});
});
});
-describe('typescript: setup package', () => {
+describe('typescript: setup package', async () => {
beforeEach(() => resetFixtures());
it('none', async () => {
@@ -113,23 +110,26 @@ describe('typescript: setup package', () => {
const packageJson = new URL('./package.json', root);
await setupTypeScript('strictest', { cwd: fileURLToPath(root), install: false });
- expect(fs.existsSync(packageJson)).to.be.false;
+ assert.ok(!fs.existsSync(packageJson));
});
it('none', async () => {
const root = new URL('./fixtures/not-empty/', import.meta.url);
const packageJson = new URL('./package.json', root);
-
- expect(JSON.parse(fs.readFileSync(packageJson, { encoding: 'utf-8' })).scripts.build).to.be.eq(
+ assert.equal(
+ JSON.parse(fs.readFileSync(packageJson, { encoding: 'utf-8' })).scripts.build,
'astro build'
);
+
await setupTypeScript('strictest', { cwd: fileURLToPath(root), install: false });
const { scripts } = JSON.parse(fs.readFileSync(packageJson, { encoding: 'utf-8' }));
- expect(Object.keys(scripts)).to.deep.eq(
+ assert.deepEqual(
+ Object.keys(scripts),
['dev', 'build', 'preview'],
'does not override existing scripts'
);
- expect(scripts.build).to.eq('astro check && astro build', 'prepends astro check command');
+
+ assert.equal(scripts.build, 'astro check && astro build', 'prepends astro check command');
});
});
diff --git a/packages/create-astro/test/utils.js b/packages/create-astro/test/utils.js
index ee7f8af5b..6a62490e9 100644
--- a/packages/create-astro/test/utils.js
+++ b/packages/create-astro/test/utils.js
@@ -1,6 +1,7 @@
import fs from 'node:fs';
import { setStdout } from '../dist/index.js';
import stripAnsi from 'strip-ansi';
+import { before, beforeEach } from 'node:test';
export function setup() {
const ctx = { messages: [] };
diff --git a/packages/create-astro/test/verify.test.js b/packages/create-astro/test/verify.test.js
index ecfaba727..9ec7e49e9 100644
--- a/packages/create-astro/test/verify.test.js
+++ b/packages/create-astro/test/verify.test.js
@@ -1,9 +1,9 @@
-import { expect } from 'chai';
-
-import { verify } from '../dist/index.js';
+import assert from 'node:assert/strict';
+import { describe, it } from 'node:test';
import { setup } from './utils.js';
+import { verify } from '../dist/index.js';
-describe('verify', () => {
+describe('verify', async () => {
const fixture = setup();
const exit = (code) => {
throw code;
@@ -12,7 +12,7 @@ describe('verify', () => {
it('basics', async () => {
const context = { template: 'basics', exit };
await verify(context);
- expect(fixture.messages().length).to.equal(0, 'Did not expect `verify` to log any messages');
+ assert.equal(fixture.messages().length, 0, 'Did not expect `verify` to log any messages');
});
it('missing', async () => {
@@ -23,19 +23,19 @@ describe('verify', () => {
} catch (e) {
err = e;
}
- expect(err).to.eq(1);
- expect(fixture.hasMessage('Template missing does not exist!'));
+ assert.equal(err, 1);
+ assert.ok(!fixture.hasMessage('Template missing does not exist!'));
});
it('starlight', async () => {
const context = { template: 'starlight', exit };
await verify(context);
- expect(fixture.messages().length).to.equal(0, 'Did not expect `verify` to log any messages');
+ assert.equal(fixture.messages().length, 0, 'Did not expect `verify` to log any messages');
});
it('starlight/tailwind', async () => {
const context = { template: 'starlight/tailwind', exit };
await verify(context);
- expect(fixture.messages().length).to.equal(0, 'Did not expect `verify` to log any messages');
+ assert.equal(fixture.messages().length, 0, 'Did not expect `verify` to log any messages');
});
});