Skip to content

Vitest #153

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

Merged
merged 14 commits into from
Oct 26, 2024
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
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

48 changes: 0 additions & 48 deletions .eslintrc.js

This file was deleted.

9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
node-version: 22
- name: restore dependencies
uses: bahmutov/npm-install@v1
- name: restore dependencies
uses: bahmutov/npm-install@v1
with:
working-directory: e2e
- run: npm run lint:all
type_check:
name: type check
Expand All @@ -39,8 +43,11 @@ jobs:
- name: restore dependencies
uses: bahmutov/npm-install@v1
- run: npm run test
- name: report coverage
if: always()
uses: davelosert/vitest-coverage-report-action@v2
e2e:
timeout-minutes: 60
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
yarn.lock
lib
dist
coverage
2 changes: 0 additions & 2 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
node_modules
yarn.lock
lib
dist
examples
coverage
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"stylelint.vscode-stylelint",
"bradlc.vscode-tailwindcss",
"csstools.postcss",
"ms-playwright.playwright"
"ms-playwright.playwright",
"vitest.explorer"
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"scss.validate": false,
"editor.codeActionsOnSave": {
"source.fixAll.markdownlint": "explicit",
"source.fixAll.stylelint": "explicit"
"source.fixAll.stylelint": "explicit",
"source.fixAll.eslint": "explicit"
},
"stylelint.validate": ["css", "scss", "postcss"]
}
1 change: 0 additions & 1 deletion e2e/test_repos/drivers/create-react-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ async function startServerWithRetry({
while (attemptNumber <= maxAttempts) {
attemptNumber++
if (attemptNumber > 1) {
// eslint-disable-next-line no-console
console.log(
`Retrying (attempt ${attemptNumber}) starting the server because: ${failedReason}`
)
Expand Down
6 changes: 4 additions & 2 deletions e2e/test_repos/drivers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class IsolatedRepoInstanceImpl implements IsolatedRepoInstance {
})
}, 20_000)
serveProcess.stderr.pipe(process.stderr)
serveProcess.stdout.on('data', chunk => {
serveProcess.stdout.on('data', (chunk: { toString(): string }) => {
if (finishedMonitoring) return
const newChunk = chunk.toString()
stdout += newChunk
Expand Down Expand Up @@ -187,7 +187,9 @@ class IsolatedRepoInstanceImpl implements IsolatedRepoInstance {
} catch (e: unknown) {
clearTimeout(failTimeout)
finishedMonitoring = true
void stop().then(() => reject(e))
void stop().then(() =>
reject(e instanceof Error ? e : new Error(JSON.stringify(e)))
)
}
})
})
Expand Down
29 changes: 14 additions & 15 deletions e2e/test_repos/templates/create-react-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion e2e/test_repos/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class TestRepoBuilderImpl implements TestRepoBuilder {

async open(): Promise<{ repo: TestRepo; root: ThemeRoot }> {
if (!this.#themerConfig) {
throw new Error('cannot open without first defining the themer config')
throw new Error('Cannot open without first defining the themer config')
}

const { url, stop: _stop } = await openWithConfig({
Expand Down Expand Up @@ -187,6 +187,8 @@ class ThemeRootImpl implements ThemeRoot {
const attributesInputLocator = this.#attributesInputLocator
return {
async get(): Promise<Record<string, string>> {
// We'll pinky promise here 🤞
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(await attributesInputLocator.inputValue())
},
async patch(updates: Record<string, string>): Promise<void> {
Expand Down
66 changes: 66 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import vitest from 'eslint-plugin-vitest'
import playwright from 'eslint-plugin-playwright'

export default tseslint.config(
{
ignores: [
'lib',
'examples',
'coverage',
'e2e/test_repos/templates',
'**/test-results',
'**/playwright-report'
]
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: true
}
},
rules: {
quotes: ['warn', 'single'],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{ varsIgnorePattern: '^_', ignoreRestSiblings: true }
],
'@typescript-eslint/no-floating-promises': 'error'
}
},
{
ignores: ['e2e/**'],
languageOptions: {
parserOptions: {
project: './tsconfig.json'
}
},
rules: {
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-argument': 'off'
}
},
{
files: ['e2e/**/*.?(c|m)[jt]s?(x)'],
languageOptions: {
parserOptions: {
project: './e2e/tsconfig.json'
}
}
},
{
files: ['src/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
...vitest.configs.recommended
},
{
...playwright.configs['flat/recommended'],
files: ['e2e/tests/**']
}
)
14 changes: 0 additions & 14 deletions jest.config.js

This file was deleted.

Loading