feat: Add support for cypress and vitest
Signed-off-by: Avior <github@avior.me>
This commit is contained in:
parent
dc80dec6a8
commit
8442c7b4e3
7
cypress.config.js
Normal file
7
cypress.config.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { defineConfig } from 'cypress'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
e2e: {
|
||||||
|
supportFile: false
|
||||||
|
}
|
||||||
|
})
|
1
cypress/.gitignore
vendored
Normal file
1
cypress/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
videos
|
5
cypress/e2e/index.cy.ts
Normal file
5
cypress/e2e/index.cy.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
it('titles are correct', () => {
|
||||||
|
const page = cy.visit('http://localhost:3000');
|
||||||
|
|
||||||
|
page.get('h1').should('have.text', 'Welcome to Astro');
|
||||||
|
});
|
8
cypress/tsconfig.json
Normal file
8
cypress/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"lib": ["es5", "dom"],
|
||||||
|
"types": ["cypress", "node"]
|
||||||
|
},
|
||||||
|
"include": ["**/*.ts"]
|
||||||
|
}
|
2410
package-lock.json
generated
2410
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@ -1,12 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "paas",
|
"name": "@fi3d/slicer-as-a-service",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
|
"type": "module",
|
||||||
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "astro dev",
|
"dev": "astro dev",
|
||||||
"start": "node ./dist/server/entry.mjs",
|
"start": "node ./dist/server/entry.mjs",
|
||||||
"build": "astro build",
|
"build": "astro build",
|
||||||
"preview": "astro preview",
|
"preview": "astro preview",
|
||||||
"astro": "astro"
|
"astro": "astro",
|
||||||
|
"test": "vitest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/node": "^5.2.0",
|
"@astrojs/node": "^5.2.0",
|
||||||
@ -19,6 +22,8 @@
|
|||||||
"tailwindcss": "^3.3.2"
|
"tailwindcss": "^3.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.3.1"
|
"@types/node": "^20.3.1",
|
||||||
|
"cypress": "^12.15.0",
|
||||||
|
"vitest": "^0.32.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
sandbox.config.json
Normal file
11
sandbox.config.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"infiniteLoopProtection": true,
|
||||||
|
"hardReloadOnChange": false,
|
||||||
|
"view": "browser",
|
||||||
|
"template": "node",
|
||||||
|
"container": {
|
||||||
|
"port": 3000,
|
||||||
|
"startScript": "start",
|
||||||
|
"node": "14"
|
||||||
|
}
|
||||||
|
}
|
21
tests/basic.test.ts
Normal file
21
tests/basic.test.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { assert, expect, test } from 'vitest'
|
||||||
|
|
||||||
|
// Edit an assertion and save to see HMR in action
|
||||||
|
|
||||||
|
test('Math.sqrt()', () => {
|
||||||
|
expect(Math.sqrt(4)).toBe(2);
|
||||||
|
expect(Math.sqrt(144)).toBe(12);
|
||||||
|
expect(Math.sqrt(2)).toBe(Math.SQRT2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('JSON', () => {
|
||||||
|
const input = {
|
||||||
|
foo: 'hello',
|
||||||
|
bar: 'world',
|
||||||
|
};
|
||||||
|
|
||||||
|
const output = JSON.stringify(input);
|
||||||
|
|
||||||
|
expect(output).eq('{"foo":"hello","bar":"world"}');
|
||||||
|
assert.deepEqual(JSON.parse(output), input, 'matches original');
|
||||||
|
});
|
13
vitest.config.ts
Normal file
13
vitest.config.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/// <reference types="vitest" />
|
||||||
|
import { getViteConfig } from 'astro/config'
|
||||||
|
import { configDefaults } from 'vitest/config'
|
||||||
|
|
||||||
|
export default getViteConfig({
|
||||||
|
test: {
|
||||||
|
include: [
|
||||||
|
'./tests/**'
|
||||||
|
]
|
||||||
|
/* for example, use global to avoid globals imports (describe, test, expect): */
|
||||||
|
// globals: true,
|
||||||
|
},
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user