Skip to content

Commit 916ab78

Browse files
authored
Merge pull request #634 from nobkd/test/setup-ci
test: setup ci
2 parents f82935e + 6b1e137 commit 916ab78

File tree

6 files changed

+48
-62
lines changed

6 files changed

+48
-62
lines changed

.github/workflows/test.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- .github/**
9+
- packages/templates/**
10+
- packages/www/**
11+
pull_request:
12+
paths-ignore:
13+
- .github/**
14+
- packages/templates/**
15+
- packages/www/**
16+
workflow_dispatch:
17+
18+
jobs:
19+
test:
20+
if: ${{ github.repository_owner == 'nuejs' || github.event_name == 'workflow_dispatch' }}
21+
strategy:
22+
matrix:
23+
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
24+
25+
runs-on: ${{ matrix.os }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- uses: oven-sh/setup-bun@v2
30+
31+
- name: Install and test with Bun
32+
run: |
33+
bun -v
34+
bun install
35+
bun test --coverage

.github/workflows/test.yaml.disabled

Lines changed: 0 additions & 55 deletions
This file was deleted.

bunfig.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[test]
2+
coveragePathIgnorePatterns = ["**/test/**", "**/test_dir/**"]

packages/nuekit/test/cmd/create.test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import { create, unzip, getLocalZip, fetchZip } from '../../src/cmd/create'
33
import { rm, readdir } from 'node:fs/promises'
44

5+
const testdir = import.meta.dirname
6+
57
// suppress console messages
68
jest.spyOn(console, 'log').mockImplementation(() => {})
79

@@ -10,7 +12,7 @@ afterEach(async () => {
1012
})
1113

1214
test('getLocalZip', async () => {
13-
const zip = await getLocalZip('minimal', 'cmd')
15+
const zip = await getLocalZip('minimal', testdir)
1416
expect(await zip.exists()).toBeTrue()
1517
})
1618

@@ -21,12 +23,12 @@ test.skip('fetchZip', async () => {
2123

2224
test('unzip', async () => {
2325
const dir = 'minimal'
24-
const zip = await getLocalZip(dir, 'cmd')
26+
const zip = await getLocalZip(dir, testdir)
2527
await unzip(dir, zip)
2628
const files = await readdir(dir)
2729
expect(new Set(files)).toEqual(new Set(["index.html", "index.css"]))
2830
})
2931

3032
test('create', async () => {
31-
expect(await create('minimal', { dir: 'cmd' })).toBeTrue()
32-
})
33+
expect(await create('minimal', { dir: testdir })).toBeTrue()
34+
})

packages/nuekit/test/render/svg.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11

22
import { renderFonts, renderHMR, renderSVG, convertHTMLTag } from '../../src/render/svg'
33

4+
const testfile = import.meta.filename
45

56
test('renderFont / inlined', async () => {
6-
const [ css ] = await renderFonts({ Test: 'render/svg.test.js' })
7+
const [ css ] = await renderFonts({ Test: testfile })
78
expect(css).toInclude('data:font/woff2;base64')
89
expect(css.length).toBeGreaterThan(200)
910
expect(css).toInclude('@font-face')
@@ -56,7 +57,7 @@ test('renderSVG', async () => {
5657

5758

5859
// SVG
59-
const svg = await renderSVG(asset, { fonts: { Test: 'render/svg.test.js' } })
60+
const svg = await renderSVG(asset, { fonts: { Test: testfile } })
6061
expect(svg).toInclude("url('data:font/woff2;base64")
6162
expect(svg).toInclude(':root{--brand:#ccc}')
6263
expect(svg).toInclude('</style></svg>')
@@ -78,4 +79,4 @@ test('custom <html> tag', () => {
7879
expect(attr.length).toBe(4)
7980
expect(children[0].attr[0].name).toEqual('xmlns')
8081

81-
})
82+
})

packages/nuestate/test/state.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
import { getPathData, getQueryData, renderPath, renderQuery, api, state } from '../src/state.js'
33

4+
beforeAll(() => global.window = null)
45

56
describe('internal methods', () => {
67

0 commit comments

Comments
 (0)