TestPipeline
Home > @backstage/plugin-search-backend-node
> TestPipeline
Test utility for Backstage Search collators, decorators, and indexers.
Signature:
class TestPipeline
Example 1
An example test checking that a collator provides expected documents.
it('provides expected documents', async () => {
const testSubject = await yourCollatorFactory.getCollator();
const pipeline = TestPipeline.fromCollator(testSubject);
const { documents } = await pipeline.execute();
expect(documents).toHaveLength(2);
})
Example 2
An example test checking that a decorator behaves as expected.
it('filters private documents', async () => {
const testSubject = await yourDecoratorFactory.getDecorator();
const pipeline = TestPipeline
.fromDecorator(testSubject)
.withDocuments([{ title: 'Private', location: '/private', text: '' }]);
const { documents } = await pipeline.execute();
expect(documents).toHaveLength(0);
})
Methods
Method |
Modifiers |
Description |
---|---|---|
Execute the test pipeline so that you can make assertions about the result or behavior of the given test subject. | ||
|
Create a test pipeline given a collator you want to test. | |
|
Create a test pipeline given a decorator you want to test. | |
|
Create a test pipeline given an indexer you want to test. | |
Add a collator to the test pipeline. | ||
Add a decorator to the test pipeline. | ||
Provide documents for testing decorators and indexers. | ||
Add an indexer to the test pipeline. | ||
|
Provide the collator, decorator, or indexer to be tested. |