Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Feb 2, 2024
1 parent 95cc6d4 commit aea0f93
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
node-version: lts/*
cache: npm
- run: npm ci
- run: npm test
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
75 changes: 74 additions & 1 deletion package-lock.json

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

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "0.0.0-development",
"description": "TypeScript configuration for Octokit packages",
"scripts": {
"test": "node -p 'require(\".\")'"
"test": "node --test ./test/*.test.js"
},
"main": "tsconfig.json",
"files": [
Expand All @@ -19,5 +19,9 @@
"branches": [
"main"
]
},
"devDependencies": {
"ajv": "^8.12.0",
"ajv-draft-04": "^1.0.0"
}
}
29 changes: 29 additions & 0 deletions test/schema.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict'

const assert = require('node:assert')
const fs = require('node:fs')
const { test } = require('node:test')
const Ajv = require("ajv-draft-04")

const customKeywords = [
"allowTrailingCommas",
"markdownDescription",
"markdownEnumDescriptions"
]

test('validate tsconfig by schema', async () => {
const schema = await (await fetch('https://json.schemastore.org/tsconfig')).json()
const ajv = new Ajv({
strict: false
});

for (const keyword of customKeywords) {
ajv.addKeyword({
keyword
})
}

const validate = ajv.compile(schema)
const tsconfig = JSON.parse(await fs.promises.readFile('tsconfig.json', 'utf-8'))
assert(validate(tsconfig), 'tsconfig.json does not match the schema')
})

0 comments on commit aea0f93

Please sign in to comment.