Skip to content

Commit

Permalink
test: avoid starting two servers concurrently in a test
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jul 3, 2022
1 parent 967dfd4 commit 6c72736
Show file tree
Hide file tree
Showing 14 changed files with 487 additions and 249 deletions.
443 changes: 443 additions & 0 deletions playground/css-sourcemap/__tests__/css-sourcemap.spec.ts

Large diffs are not rendered by default.

219 changes: 0 additions & 219 deletions playground/css-sourcemap/__tests__/serve.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getBgColor, getColor, page, ports } from '~utils'
test('postcss plugins in different dir', async () => {
const port = ports['css/postcss-plugins-different-dir']
const server = await createServer({
root: path.join(__dirname, '..', '..', 'tailwind'),
root: path.join(__dirname, '..', '..', '..', 'tailwind'),
logLevel: 'silent',
server: {
port,
Expand Down
10 changes: 10 additions & 0 deletions playground/css/__tests__/postcss-plugins-different-dir/serve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// this is automatically detected by playground/vitestSetup.ts and will replace
// the default e2e test serve behavior

// The server is started in the test, so we need to have a custom serve
// function or a default server will be created
export async function serve(): Promise<{ close(): Promise<void> }> {
return {
close: () => Promise.resolve()
}
}
10 changes: 10 additions & 0 deletions playground/css/postcss-caching/serve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// this is automatically detected by playground/vitestSetup.ts and will replace
// the default e2e test serve behavior

// The server is started in the test, so we need to have a custom serve
// function or a default server will be created
export async function serve(): Promise<{ close(): Promise<void> }> {
return {
close: () => Promise.resolve()
}
}
7 changes: 0 additions & 7 deletions playground/js-sourcemap/__tests__/build.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ if (!isBuild) {
expect(true).toBe(true)
})
}

test.runIf(isBuild)('should not output sourcemap warning (#4939)', () => {
serverLogs.forEach((log) => {
expect(log).not.toMatch('Sourcemap is likely to be incorrect')
})
})
7 changes: 0 additions & 7 deletions playground/tailwind-sourcemap/__tests__/build.spec.ts

This file was deleted.

7 changes: 0 additions & 7 deletions playground/tailwind-sourcemap/__tests__/serve.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { isBuild, serverLogs } from '~utils'

test.runIf(!isBuild)('should not output missing source file warning', () => {
serverLogs.forEach((log) => {
expect(log).not.toMatch(/Sourcemap for .+ points to missing source files/)
})
})

test.runIf(isBuild)('should not output sourcemap warning (#4939)', () => {
serverLogs.forEach((log) => {
expect(log).not.toMatch('Sourcemap is likely to be incorrect')
Expand Down
2 changes: 2 additions & 0 deletions playground/tailwind-sourcemap/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
console.log(__dirname + '/tailwind.config.js')

module.exports = {
plugins: {
tailwindcss: { config: __dirname + '/tailwind.config.js' }
Expand Down
7 changes: 0 additions & 7 deletions playground/vue-sourcemap/__tests__/build.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { URL } from 'node:url'
import {
extractSourcemap,
formatSourcemapForSnapshot,
isBuild,
isServe,
page
page,
serverLogs
} from '~utils'

describe.runIf(isServe)('serve:vue-sourcemap', () => {
Expand Down Expand Up @@ -98,3 +100,9 @@ describe.runIf(isServe)('serve:vue-sourcemap', () => {
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
})
})

test.runIf(isBuild)('should not output sourcemap warning (#4939)', () => {
serverLogs.forEach((log) => {
expect(log).not.toMatch('Sourcemap is likely to be incorrect')
})
})

0 comments on commit 6c72736

Please sign in to comment.