Skip to content

Commit

Permalink
Add failing Vite v4 compat test
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy authored and AriaMinaei committed Oct 5, 2023
1 parent 33df598 commit 6a3adce
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
40 changes: 40 additions & 0 deletions compat-tests/fixtures/basic-vite4/basic-vite4.compat-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// @cspotcode/zx is zx in CommonJS
import {$, cd, path, ProcessPromise} from '@cspotcode/zx'
import {testServerAndPage} from '../../utils/testUtils'

const PATH_TO_PACKAGE = path.join(__dirname, `./package`)

describe(`basic-vite4`, () => {
test(`\`$ vite build\` should succeed`, async () => {
cd(PATH_TO_PACKAGE)
const {exitCode} = await $`npm run build`
// at this point, the build should have succeeded
expect(exitCode).toEqual(0)
})

describe(`vite preview`, () => {
function startServerOnPort(port: number): ProcessPromise<unknown> {
cd(PATH_TO_PACKAGE)

return $`npm run preview -- --port ${port}`
}

testServerAndPage({
startServerOnPort,
checkServerStdoutToSeeIfItsReady: (chunk) => chunk.includes('--host'),
})
})

describe(`vite dev`, () => {
function startServerOnPort(port: number): ProcessPromise<unknown> {
cd(PATH_TO_PACKAGE)

return $`npm run dev -- --port ${port}`
}

testServerAndPage({
startServerOnPort,
checkServerStdoutToSeeIfItsReady: (chunk) => chunk.includes('--host'),
})
})
})
3 changes: 3 additions & 0 deletions compat-tests/fixtures/basic-vite4/package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.cache
/dist
/package-lock.json
2 changes: 2 additions & 0 deletions compat-tests/fixtures/basic-vite4/package/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<script type="module" src="./src/index.ts"></script>
20 changes: 20 additions & 0 deletions compat-tests/fixtures/basic-vite4/package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@theatre/core": "0.0.1-COMPAT.1",
"@theatre/studio": "0.0.1-COMPAT.1"
},
"browserslist": {
"production": [">0.2%", "not dead", "not op_mini all"],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
9 changes: 9 additions & 0 deletions compat-tests/fixtures/basic-vite4/package/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {getProject} from '@theatre/core'

const project = getProject('Sample project')
const sheet = project.sheet('Scene')

if (import.meta.env.MODE === 'development') {
const {default: studio} = await import('@theatre/studio')
studio.initialize()
}
9 changes: 9 additions & 0 deletions compat-tests/fixtures/basic-vite4/package/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"include": ["./src/**/*.ts"],
"compilerOptions": {
"types": ["vite/client"],
"moduleResolution": "NodeNext",
"module": "NodeNext",
"target": "ESNext"
}
}

1 comment on commit 6a3adce

@vercel
Copy link

@vercel vercel bot commented on 6a3adce Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.