0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

feat: work on remaining tests

This commit is contained in:
Florian Lefebvre 2024-08-22 17:29:17 +02:00
parent a0269c54a3
commit 7ecc2bac3e
5 changed files with 53 additions and 8 deletions

1
.astro/types.d.ts vendored Normal file
View file

@ -0,0 +1 @@
/// <reference types="astro/client" />

View file

@ -3,6 +3,8 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*"
"@astrojs/check": "^0.9.3",
"astro": "workspace:*",
"typescript": "^5.5.4"
}
}

View file

@ -27,6 +27,13 @@ const createFixture = async (config = {}) => {
return {
sync: () => astroFixture.sync({ root: stringRoot, ...config }),
build: () => astroFixture.build({ root: stringRoot, ...config }),
check: async () => {
// TODO: check how this thing works
// @ts-ignore
return await astroFixture.check({ flags: { root: stringRoot, ...config } });
},
startDevServer: () => astroFixture.startDevServer({ root: stringRoot, ...config }),
/** @param {string} path */
fileExists: (path) => {
return existsSync(new URL(path, root));
@ -66,6 +73,12 @@ describe('experimental.typescript', () => {
assert.equal(fixture.fileExists(SRC_ENV_DTS), true);
});
it('should create a tsconfig.json if it does not exist yet', async () => {
const fixture = await createFixture({ experimental: { typescript: {} } });
await fixture.sync();
assert.equal(fixture.fileExists(ROOT_TSCONFIG_PATH), true);
});
it('should throw if tsconfig.json has invalid extends', async () => {
const fixture = await createFixture({ experimental: { typescript: {} } });
@ -142,13 +155,33 @@ describe('experimental.typescript', () => {
}
});
// it('should work with astro check', async () => {});
// TODO: check why it fails other tests
it.skip('should work in dev', async () => {
const fixture = await createFixture({ experimental: { typescript: {} } });
try {
const devServer = await fixture.startDevServer();
await devServer.stop();
assert.ok(true);
} catch {
assert.fail();
}
});
// it('should work in dev', async () => {});
it('should work in build', async () => {
const fixture = await createFixture({ experimental: { typescript: {} } });
try {
await fixture.build();
assert.ok(true);
} catch {
assert.fail();
}
});
// 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 () => {});
// TODO: check how check works
it.skip('should work with astro check', async () => {
const fixture = await createFixture({ experimental: { typescript: {} } });
await fixture.build();
const res = await fixture.check();
console.log({ res });
});
});

View file

@ -2459,9 +2459,15 @@ importers:
packages/astro/test/fixtures/astro-typescript:
dependencies:
'@astrojs/check':
specifier: ^0.9.3
version: 0.9.3(prettier-plugin-astro@0.14.1)(prettier@3.3.3)(typescript@5.5.4)
astro:
specifier: workspace:*
version: link:../../..
typescript:
specifier: ^5.5.4
version: 5.5.4
packages/astro/test/fixtures/before-hydration:
dependencies:
@ -9250,10 +9256,12 @@ packages:
libsql@0.3.19:
resolution: {integrity: sha512-Aj5cQ5uk/6fHdmeW0TiXK42FqUlwx7ytmMLPSaUQPin5HKKKuUPD62MAbN4OEweGBBI7q1BekoEN4gPUEL6MZA==}
cpu: [x64, arm64, wasm32]
os: [darwin, linux, win32]
libsql@0.4.1:
resolution: {integrity: sha512-qZlR9Yu1zMBeLChzkE/cKfoKV3Esp9cn9Vx5Zirn4AVhDWPcjYhKwbtJcMuHehgk3mH+fJr9qW+3vesBWbQpBg==}
cpu: [x64, arm64, wasm32]
os: [darwin, linux, win32]
lilconfig@2.1.0:

1
src/env.d.ts vendored Normal file
View file

@ -0,0 +1 @@
/// <reference path="../.astro/types.d.ts" />