MCPcopy Index your code
hub / github.com/formatjs/formatjs / transformAndCheck

Function transformAndCheck

packages/babel-plugin-formatjs/tests/index.test.ts:10–28  ·  view source on GitHub ↗
(fn: string, opts: Options = {})

Source from the content-addressed store, hash-verified

8} from '#packages/babel-plugin-formatjs/types.js'
9import {expect, test} from 'vitest'
10function transformAndCheck(fn: string, opts: Options = {}) {
11 const filePath = path.join(import.meta.dirname, 'fixtures', `${fn}.js`)
12 const messages: ExtractedMessageDescriptor[] = []
13 const meta = {}
14 const {code} = transform(filePath, {
15 pragma: '@react-intl',
16 ...opts,
17 onMsgExtracted(_, msgs) {
18 messages.push(...msgs)
19 },
20 onMetaExtracted(_, m) {
21 Object.assign(meta, m)
22 },
23 })
24 return {
25 data: {messages, meta},
26 code: code?.trim(),
27 }
28}
29
30test('additionalComponentNames', function () {
31 transformAndCheck('additionalComponentNames', {

Callers 1

index.test.tsFile · 0.85

Calls 1

transformFunction · 0.70

Tested by

no test coverage detected