Skip to content

Commit 4bf0e13

Browse files
Rebuild testing setup (#1226)
This PR basically rebuilds the testing infra with code in place to keep existing tests working. This was done so we can add tests for the CSS language server in a followup PR.
1 parent 4d50880 commit 4bf0e13

File tree

15 files changed

+1206
-510
lines changed

15 files changed

+1206
-510
lines changed

packages/tailwindcss-language-server/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function getDefaultSettings(): Settings {
1212
return {
1313
editor: { tabSize: 2 },
1414
tailwindCSS: {
15+
inspectPort: null,
1516
emmetCompletions: false,
1617
classAttributes: ['class', 'className', 'ngClass', 'class:list'],
1718
codeActions: true,

packages/tailwindcss-language-server/src/testing/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { afterAll, onTestFinished, test, TestOptions } from 'vitest'
1+
import { onTestFinished, test, TestOptions } from 'vitest'
22
import * as fs from 'node:fs/promises'
33
import * as path from 'node:path'
44
import * as proc from 'node:child_process'
@@ -16,7 +16,7 @@ export interface Storage {
1616

1717
export interface TestConfig<Extras extends {}> {
1818
name: string
19-
fs: Storage
19+
fs?: Storage
2020
prepare?(utils: TestUtils): Promise<Extras>
2121
handle(utils: TestUtils & Extras): void | Promise<void>
2222

@@ -43,8 +43,10 @@ async function setup<T>(config: TestConfig<T>): Promise<TestUtils> {
4343

4444
await fs.mkdir(baseDir, { recursive: true })
4545

46-
await prepareFileSystem(baseDir, config.fs)
47-
await installDependencies(baseDir, config.fs)
46+
if (config.fs) {
47+
await prepareFileSystem(baseDir, config.fs)
48+
await installDependencies(baseDir, config.fs)
49+
}
4850

4951
onTestFinished(async (result) => {
5052
// Once done, move all the files to a new location

packages/tailwindcss-language-server/src/tw.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ export class TW {
553553
configTailwindVersionMap.get(projectConfig.configPath),
554554
userLanguages,
555555
resolver,
556+
baseUri,
556557
),
557558
),
558559
)
@@ -663,6 +664,11 @@ export class TW {
663664
}),
664665
)
665666
}
667+
668+
// TODO: This is a hack and shouldn't be necessary
669+
if (isTestMode) {
670+
await this.connection.sendNotification('@/tailwindCSS/serverReady')
671+
}
666672
}
667673

668674
private filterNewWatchPatterns(patterns: string[]) {
@@ -684,6 +690,7 @@ export class TW {
684690
tailwindVersion: string,
685691
userLanguages: Record<string, string>,
686692
resolver: Resolver,
693+
baseUri: URI,
687694
): Promise<void> {
688695
let key = String(this.projectCounter++)
689696
const project = await createProjectService(
@@ -717,6 +724,7 @@ export class TW {
717724
}
718725

719726
this.connection.sendNotification('@/tailwindCSS/projectDetails', {
727+
uri: baseUri.toString(),
720728
config: projectConfig.configPath,
721729
tailwind: projectConfig.tailwind,
722730
})

0 commit comments

Comments
 (0)