Skip to content

Commit

Permalink
Merge pull request #842 from storyblok/chore/PRO-168-refactor-tests
Browse files Browse the repository at this point in the history
chore(tests): pro 168 refactor tests
  • Loading branch information
alvarosabu authored Aug 23, 2024
2 parents b1b72c4 + 8b0db78 commit c8a3a45
Show file tree
Hide file tree
Showing 34 changed files with 2,134 additions and 2,496 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ jobs:
test:
runs-on: ubuntu-latest
environment: test
strategy:
matrix:
node-version: [20]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -24,11 +27,5 @@ jobs:
run: pnpm install
- run: pnpm run lint
- run: pnpm run prettier . --check
- name: Sets all variables to unit tests
env:
VITE_ACCESS_TOKEN: ${{ secrets.VITE_ACCESS_TOKEN }}
VITE_OAUTH_TOKEN: ${{ secrets.VITE_OAUTH_TOKEN }}
VITE_SPACE_ID: ${{ vars.VITE_SPACE_ID }}
run: pnpm run test

- run: pnpm run build
8 changes: 5 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ jobs:
name: Publish to npm
runs-on: ubuntu-latest
environment: production

strategy:
matrix:
node-version: [20]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm

- name: Install dependencies
run: pnpm install

- name: Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Run Tests
on: [push]

env:
PNPM_CACHE_FOLDER: .pnpm-store
HUSKY: 0 # Bypass husky commit hook for CI

jobs:
test:
name: Tests
runs-on: ubuntu-latest
environment: test
strategy:
matrix:
node-version: [20]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Run Unit tests
run: pnpm run test
- name: Run E2E tests
env:
VITE_ACCESS_TOKEN: ${{ secrets.VITE_ACCESS_TOKEN }}
VITE_OAUTH_TOKEN: ${{ secrets.VITE_OAUTH_TOKEN }}
VITE_SPACE_ID: ${{ vars.VITE_SPACE_ID }}
run: pnpm run build && pnpm run test:e2e
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ gitcommit.fish

.env.test
.env
.next
.next

old-tests/
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Vitest Tests",
"program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
"args": ["run"],
"autoAttachChildProcesses": true,
"smartStep": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": ["<node_internals>/**"]
},
{
"type": "node",
"request": "launch",
"name": "Debug Vitest E2E Tests",
"program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
"args": ["run", "-c", "vitest.config.e2e.ts"],
"autoAttachChildProcesses": true,
"smartStep": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": ["<node_internals>/**"]
}
]
}
18 changes: 0 additions & 18 deletions index.html

This file was deleted.

19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
"demo": "vite serve playground",
"dev:umd": "npx serve ./",
"test": "vitest run",
"test:e2e": "vitest run -c vitest.config.e2e.ts",
"test:ui": "vitest --ui --coverage.enabled=true",
"coverage": "vitest run --coverage",
"prepare": "npm run build"
},
"repository": {
Expand All @@ -59,20 +62,22 @@
"devDependencies": {
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@tsconfig/recommended": "^1.0.3",
"@tsconfig/recommended": "^1.0.7",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"@vitest/coverage-v8": "^2.0.5",
"@vitest/ui": "^2.0.5",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"husky": "^9.0.6",
"husky": "^9.1.5",
"isomorphic-fetch": "^3.0.0",
"kolorist": "^1.8.0",
"prettier": "^3.1.0",
"typescript": "^5.3.2",
"vite": "^5.0.2",
"prettier": "^3.3.3",
"typescript": "^5.5.4",
"vite": "^5.4.2",
"vite-plugin-banner": "^0.7.1",
"vite-plugin-dts": "^3.9.1",
"vitest": "^1.0.4"
"vite-plugin-dts": "^4.0.3",
"vitest": "^2.0.5"
},
"release": {
"branches": [
Expand Down
2 changes: 1 addition & 1 deletion playground/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@tsconfig/svelte": "^5.0.2",
"svelte": "^4.2.8",
"vite": "^5.0.10"
"vite": "^5.4.2"
},
"dependencies": {
"storyblok-js-client": "file:.."
Expand Down
7 changes: 7 additions & 0 deletions playground/vanilla/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import StoryblokClient from 'storyblok-js-client'
import './style.css'

const headers = new Headers()
headers.append('Awiwi', 'Awiwi')

// 2. Initialize the client with the preview token
// from your space dashboard at https://app.storyblok.com
const Storyblok = new StoryblokClient({
accessToken: import.meta.env.VITE_ACCESS_TOKEN as string,
headers,
})

try {
const result = await Storyblok.get('cdn/stories/', {
version: 'draft',
resolve_relations: 'root.author',
})

console.log(Storyblok.cacheVersions())

document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
<pre>
<code>
Expand Down
1 change: 0 additions & 1 deletion playground/vanilla/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ h1 {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
Expand Down
Loading

0 comments on commit c8a3a45

Please sign in to comment.