Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing Vite v4 compatibility test #453

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}