Skip to content

Commit

Permalink
feat: add dist tests -d
Browse files Browse the repository at this point in the history
  • Loading branch information
arpowers committed Mar 10, 2024
1 parent c0ea7c9 commit 361a636
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ jobs:
if: env.SHOULD_DEPLOY
run: npm exec -- fiction run render

- name: DIST unit tests
run: npm exec -- vitest run dist -u

- name: Install FlyCtl
if: env.SHOULD_DEPLOY
uses: superfly/flyctl-actions/setup-flyctl@master
Expand Down
32 changes: 32 additions & 0 deletions @fiction/www/test/builtFiles.dist.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, it } from 'vitest'
import fs from 'fs-extra'
import { safeDirname } from '@fiction/core'

describe('files built', () => {
const dir = safeDirname(import.meta.url, '..')
const distDir = `${dir}/dist`
it('has dist files', async () => {
const files = await fs.readdir(distDir)

const expectedDirs = ['app', 'sites']
expect(files).toEqual(expect.arrayContaining(expectedDirs))

const expectedFiles = ['client', 'server']

for (const dir of expectedDirs) {
const dirFiles = await fs.readdir(`${distDir}/${dir}`)
expect(dirFiles).toEqual(expect.arrayContaining(expectedFiles))
}

const clientFiles = ['index.html', 'assets']
const serverFiles = ['mount.js', 'assets']

const clientDirFiles = await fs.readdir(`${distDir}/app/client`)

expect(clientDirFiles).toEqual(expect.arrayContaining(clientFiles))

Check failure on line 26 in @fiction/www/test/builtFiles.dist.test.ts

View workflow job for this annotation

GitHub Actions / build and test

@fiction/www/test/builtFiles.dist.test.ts > files built > has dist files

AssertionError: expected [ 'CalSans-SemiBold.woff', …(9) ] to deeply equal { Object ($$typeof, sample, ...) } - Expected + Received - ArrayContaining [ - "index.html", - "assets", + Array [ + "CalSans-SemiBold.woff", + "CalSans-SemiBold.woff2", + "_redirects", + "favicon-slate.png", + "favicon.png", + "icon-blue.png", + "icon-pink.png", + "icon-white.png", + "robots.txt", + "social-image.jpg", ] ❯ @fiction/www/test/builtFiles.dist.test.ts:26:28

const serverDirFiles = await fs.readdir(`${distDir}/app/server`)

expect(serverDirFiles).toEqual(expect.arrayContaining(serverFiles))
})
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"unit:dev": "npm exec -- vitest wip",
"unit:e2e": "npm exec -- vitest e2e",
"unit:all": "npm exec -- vitest wip && npm exec -- vitest ci && npm exec -- vitest build",
"unit:dist": "npm exec -- vitest dist",
"unit:coverage": "npm exec -- vitest wip ci ui --coverage --ui",
"types:ci": "npm exec -- vue-tsc",
"types:dev": "npm exec -- vue-tsc --watch",
Expand Down

0 comments on commit 361a636

Please sign in to comment.