CoolFace
Apppublic

strong-tie/inbound-calls

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
error-serializer.test.js37 linesDownload Raw Back to build
1'use strict'2 3const { test } = require('node:test')4const fs = require('node:fs')5const path = require('node:path')6const { loadESLint } = require('eslint')7 8const { code } = require('../../build/build-error-serializer')9 10function unifyLineBreak (str) {11  return str.toString().replace(/\r\n/g, '\n')12}13 14test('check generated code syntax', async (t) => {15  t.plan(1)16 17  // standard is a esm, we import it like this18  const Eslint = await loadESLint({ useFlatConfig: true })19  const eslint = new Eslint()20  const result = await eslint.lintText(code)21 22  // if there are any invalid syntax23  // fatal count will be greater than 024  t.assert.strictEqual(result[0].fatalErrorCount, 0)25})26 27const isPrepublish = !!process.env.PREPUBLISH28 29test('ensure the current error serializer is latest', { skip: !isPrepublish }, async (t) => {30  t.plan(1)31 32  const current = await fs.promises.readFile(path.resolve('lib/error-serializer.js'))33 34  // line break should not be a problem depends on system35  t.assert.strictEqual(unifyLineBreak(current), unifyLineBreak(code))36})37