Skip to content

Commit

Permalink
ci: disabling tests with maybe function for CI environments
Browse files Browse the repository at this point in the history
The `maybe` function has been introduced in the `fts.spec.ts` test file to skip tests when in a continuous integration environment. The beforeAll hook using delay has been removed, since test cases are either run or skipped based on the process environment, thereby improving test execution efficiency
  • Loading branch information
gsi-alejandro authored and ejscribner committed Jan 24, 2024
1 parent a7d67a8 commit c9af0b1
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions __test__/fts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
import { searchQuery, SearchQuery } from '../src';
import { delay } from './testData';

beforeAll(async () => {
await delay(15000);
});
const maybe = process.env.CI ? test.skip : test;

test('fts match results', async () => {
maybe('fts match results', async () => {
const result = await searchQuery('hotels', SearchQuery.match('Gillingham'), { limit: 5 });
expect(result).toBeDefined();
expect(result.rows.length).toBeGreaterThanOrEqual(1);
expect(result.rows[0].id).toBeDefined();
});

test('fts matchPhrase basic', async () => {
maybe('fts matchPhrase basic', async () => {
const result = await searchQuery('hotels', SearchQuery.matchPhrase('Medway Youth Hostel'), { limit: 5 });
expect(result).toBeDefined();
expect(result.rows.length).toBeGreaterThanOrEqual(1);
expect(result.rows[0].id).toBe('hotel_10025');
});

test('fts conjuncts results', async () => {
maybe('fts conjuncts results', async () => {
const query = SearchQuery.conjuncts(SearchQuery.match('Berkeley'), SearchQuery.matchPhrase('luxury hotel'));
const result = await searchQuery('hotels', query);
expect(result).toBeDefined();
expect(result.rows.length).toBeGreaterThanOrEqual(1);
expect(result.rows[0].id).toBeDefined();
});

test('fts disjunction results', async () => {
maybe('fts disjunction results', async () => {
const query = SearchQuery.disjuncts(SearchQuery.match('Louvre'), SearchQuery.match('Eiffel'));
const result = await searchQuery('hotels', query);
expect(result).toBeDefined();
Expand Down

0 comments on commit c9af0b1

Please sign in to comment.