Skip to content

Commit af68342

Browse files
Merge #202
202: Remove jest types from tsconfig r=curquiza a=Strift # Pull Request ## Related issue Error when publishing the extension ``` Extension: meilisearch/firestore-meilisearch State: Published Latest Version: 0.1.12 Version in Extensions Hub: 0.1.12 Source in GitHub: Local source ? Enter the GitHub repo URI where this extension's source code is located: https://github.com/meilisearch/firestore-meilisearch ? Enter this extension's root directory in the repo (defaults to previous root if set): / ? Enter the commit hash, branch, or tag name to build from in the repo: HEAD Validating source code at https://github.com/meilisearch/firestore-meilisearch/tree/HEAD/... ? Choose the release stage: Stable (0.3.0, automatically sent for review) You are about to upload a new version to Firebase's registry of extensions. Extension: meilisearch/firestore-meilisearch Version: 0.3.0 (automatically sent for review) Source: https://github.com/meilisearch/firestore-meilisearch/tree/HEAD/ Release notes: Breaking: Update nodejs runtime to node20 (#179) `@brunoocasali` Once an extension version is uploaded, it becomes installable by other users and cannot be changed. If you wish to make changes after uploading, you will need to upload a new version. ? Do you wish to continue? Yes ✖ Uploading meilisearch/firestore-meilisearch@0.3.0... Error: generic::invalid_argument: failed to build ExtensionVersion "publishers/meilisearch/extensions/firestore-meilisearch/versions/0.3.0" source: failed to build NPM package: Pulling image: us-docker.pkg.dev/extensions-builder-prod/extensions-builder/builder Using default tag: latest latest: Pulling from extensions-builder-prod/extensions-builder/builder 3153aa388d02: Pulling fs layer ef57089adb55: Pulling fs layer 792066ee936e: Pulling fs layer 9ed9b1b2bc55: Pulling fs layer 9ed9b1b2bc55: Waiting 3153aa388d02: Verifying Checksum 3153aa388d02: Download complete 9ed9b1b2bc55: Verifying Checksum 9ed9b1b2bc55: Download complete ef57089adb55: Download complete 792066ee936e: Verifying Checksum 792066ee936e: Download complete 3153aa388d02: Pull complete ef57089adb55: Pull complete 792066ee936e: Pull complete 9ed9b1b2bc55: Pull complete Digest: sha256:3f9b4d6c7b66b5859a7d894cd23d8ddcf78a23dcee2959a79ef99a5c8c41b81b Status: Downloaded newer image for us-docker.pkg.dev/extensions-builder-prod/extensions-builder/builder:latest us-docker.pkg.dev/extensions-builder-prod/extensions-builder/builder:latest Now using node v20.4.0 (npm v9.7.2) > firestore-meilisearch@0.3.0 build > tsc error TS2688: Cannot find type definition file for 'jest'. The file is in the program because: Entry point of type library 'jest' specified in compilerOptions ``` ## What does this PR do? - Move `jest` types to `functions/__tests__/tsconfig.json` - Fix ensuing type errors ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: Strift <lau.cazanove@gmail.com>
2 parents 55f9f25 + 7465c0c commit af68342

File tree

8 files changed

+46
-12
lines changed

8 files changed

+46
-12
lines changed

functions/__tests__/adapter.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, test, expect } from '@jest/globals'
12
import * as firebaseFunctionsTestInit from 'firebase-functions-test'
23
import { mockConsoleInfo } from './__mocks__/console'
34
import * as firestore from 'firebase-admin/firestore'

functions/__tests__/config.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
import {
2+
describe,
3+
test,
4+
expect,
5+
beforeEach,
6+
afterEach,
7+
jest,
8+
} from '@jest/globals'
19
import { readFileSync } from 'fs'
210
import { resolve as pathResolve } from 'path'
311
import * as yaml from 'js-yaml'

functions/__tests__/functions.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
import {
2+
describe,
3+
test,
4+
expect,
5+
beforeEach,
6+
afterEach,
7+
jest,
8+
} from '@jest/globals'
19
import * as firebaseFunctionsTestInit from 'firebase-functions-test'
210
import mockedEnv from 'mocked-env'
311
import { mocked } from 'jest-mock'
@@ -49,6 +57,7 @@ describe('extension', () => {
4957
test('functions are exported', () => {
5058
const exportedFunctions = jest.requireActual('../src')
5159

60+
// @ts-ignore: We're asserting the export is a function
5261
expect(exportedFunctions.indexingWorker).toBeInstanceOf(Function)
5362
})
5463

functions/__tests__/tsconfig.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"extends": "../tsconfig.json",
3-
"files": ["test.types.d.ts"],
4-
"include": ["**/*"]
3+
"compilerOptions": {
4+
"types": [
5+
"jest",
6+
"node"
7+
]
8+
},
9+
"files": [
10+
"test.types.d.ts"
11+
],
12+
"include": [
13+
"**/*"
14+
]
515
}

functions/__tests__/util.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
import {
2+
describe,
3+
test,
4+
expect,
5+
beforeEach,
6+
afterEach,
7+
jest,
8+
} from '@jest/globals'
19
import * as firebaseFunctionsTestInit from 'firebase-functions-test'
210
import mockedEnv from 'mocked-env'
311
import { ChangeType, getChangedDocumentId, getChangeType } from '../src/util'
@@ -151,38 +159,34 @@ describe('getFieldsToIndex', () => {
151159
test('return empty list', () => {
152160
adapter = require('../src/meilisearch-adapter')
153161
mockParseFieldsToIndex = adapter.parseFieldsToIndex()
154-
expect(mockParseFieldsToIndex).toMatchObject([])
162+
expect(mockParseFieldsToIndex).toEqual([])
155163
})
156164

157165
test('return list with one field', () => {
158166
adapter = require('../src/meilisearch-adapter')
159167
mockParseFieldsToIndex = adapter.parseFieldsToIndex('field')
160-
expect(mockParseFieldsToIndex).toMatchObject(['field'])
168+
expect(mockParseFieldsToIndex).toEqual(['field'])
161169
})
162170

163171
test('return list with multiple fields', () => {
164172
adapter = require('../src/meilisearch-adapter')
165173
mockParseFieldsToIndex = adapter.parseFieldsToIndex('field1,field2,field3')
166-
expect(mockParseFieldsToIndex).toMatchObject(['field1', 'field2', 'field3'])
174+
expect(mockParseFieldsToIndex).toEqual(['field1', 'field2', 'field3'])
167175
})
168176

169177
test('return list with multiple fields and spaces', () => {
170178
adapter = require('../src/meilisearch-adapter')
171179
mockParseFieldsToIndex = adapter.parseFieldsToIndex(
172180
'field1, field2, field3'
173181
)
174-
expect(mockParseFieldsToIndex).toMatchObject(['field1', 'field2', 'field3'])
182+
expect(mockParseFieldsToIndex).toEqual(['field1', 'field2', 'field3'])
175183
})
176184

177185
test('return list of fiels with underscore', () => {
178186
adapter = require('../src/meilisearch-adapter')
179187
mockParseFieldsToIndex = adapter.parseFieldsToIndex(
180188
'field_1,field_2,field_3'
181189
)
182-
expect(mockParseFieldsToIndex).toMatchObject([
183-
'field_1',
184-
'field_2',
185-
'field_3',
186-
])
190+
expect(mockParseFieldsToIndex).toEqual(['field_1', 'field_2', 'field_3'])
187191
})
188192
})

functions/package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

functions/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"devDependencies": {
3232
"@babel/preset-typescript": "^7.15.0",
33+
"@jest/globals": "^29.7.0",
3334
"@types/jest": "^27.0.2",
3435
"@typescript-eslint/eslint-plugin": "^4.32.0",
3536
"@typescript-eslint/parser": "^4.32.0",

functions/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"strict": true,
1010
"target": "es2018",
1111
"types": [
12-
"jest",
1312
"node",
1413
]
1514
},
@@ -19,5 +18,6 @@
1918
],
2019
"exclude": [
2120
"node_modules",
21+
"**/__tests__/**"
2222
]
2323
}

0 commit comments

Comments
 (0)