mirror of
https://github.com/withastro/astro.git
synced 2025-02-03 22:29:08 -05:00
feat: setup test
This commit is contained in:
parent
a73a89a311
commit
1236c13147
6 changed files with 82 additions and 0 deletions
1
packages/astro/test/fixtures/astro-typescript/.gitignore
vendored
Normal file
1
packages/astro/test/fixtures/astro-typescript/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
tsconfig.json
|
4
packages/astro/test/fixtures/astro-typescript/astro.config.mjs
vendored
Normal file
4
packages/astro/test/fixtures/astro-typescript/astro.config.mjs
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
import { defineConfig } from 'astro/config';
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({});
|
8
packages/astro/test/fixtures/astro-typescript/package.json
vendored
Normal file
8
packages/astro/test/fixtures/astro-typescript/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@test/astro-typescript",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
0
packages/astro/test/fixtures/astro-typescript/src/.gitkeep
vendored
Normal file
0
packages/astro/test/fixtures/astro-typescript/src/.gitkeep
vendored
Normal file
63
packages/astro/test/typescript.test.js
Normal file
63
packages/astro/test/typescript.test.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
// @ts-check
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { existsSync, rmSync } from 'node:fs';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Omit<import('../dist/types/public/config.js').AstroUserConfig, "root">} config
|
||||
* @returns
|
||||
*/
|
||||
const createFixture = async (config = {}) => {
|
||||
/** @type {Awaited<ReturnType<typeof loadFixture>>} */
|
||||
const astroFixture = await loadFixture({ root: './fixtures/astro-typescript/', ...config });
|
||||
const { root } = astroFixture.config;
|
||||
const stringRoot = fileURLToPath(root);
|
||||
rmSync(new URL('./tsconfig.json', root), { force: true });
|
||||
rmSync(new URL('./src/env.d.ts', root), { force: true });
|
||||
rmSync(new URL('./.astro', root), { force: true, recursive: true });
|
||||
|
||||
return {
|
||||
sync: () => astroFixture.sync({ root: stringRoot }),
|
||||
/** @param {string} path */
|
||||
fileExists: (path) => {
|
||||
return existsSync(new URL(path, root));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
describe('experimental.typescript', () => {
|
||||
it('should create .astro/tsconfig.json if experimental.typescript is enabled', async () => {
|
||||
const fixture = await createFixture({ experimental: { typescript: {} } });
|
||||
await fixture.sync();
|
||||
assert.equal(fixture.fileExists('./.astro/tsconfig.json'), true);
|
||||
});
|
||||
|
||||
it('should not create src/env.d.ts if experimental.typescript is enabled', async () => {});
|
||||
|
||||
it('should not create .astro/tsconfig.json if experimental.typescript is disabled', async () => {});
|
||||
|
||||
it('should create src/env.d.ts if experimental.typescript is disabled', async () => {});
|
||||
|
||||
it('should throw if tsconfig.json has invalid extends', async () => {});
|
||||
|
||||
it('should throw if tsconfig.json has invalid include', async () => {});
|
||||
|
||||
it('should throw if tsconfig.json has invalid exclude', async () => {});
|
||||
|
||||
it('should add outDir to .astro/tsconfig.json', async () => {});
|
||||
|
||||
it('should handle include/exclude relative paths', async () => {});
|
||||
|
||||
it('should work with astro check', async () => {});
|
||||
|
||||
it('should work in dev', async () => {});
|
||||
|
||||
it('should work in build', async () => {});
|
||||
|
||||
it('should work in sync', async () => {});
|
||||
|
||||
it('should create a tsconfig.json if it does not exist yet', async () => {});
|
||||
});
|
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
|
@ -2457,6 +2457,12 @@ importers:
|
|||
specifier: ^3.4.38
|
||||
version: 3.4.38(typescript@5.5.4)
|
||||
|
||||
packages/astro/test/fixtures/astro-typescript:
|
||||
dependencies:
|
||||
astro:
|
||||
specifier: workspace:*
|
||||
version: link:../../..
|
||||
|
||||
packages/astro/test/fixtures/before-hydration:
|
||||
dependencies:
|
||||
'@astrojs/preact':
|
||||
|
|
Loading…
Add table
Reference in a new issue