chore: updating some changeset and api-reports
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -1,6 +1,26 @@
|
||||
---
|
||||
'@backstage/backend-common': patch
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Switch out `sucrase` for `swc` for transpilation
|
||||
Switch out `sucrase` for `swc` for transpilation.
|
||||
|
||||
Sucrase is a little more relaxed when it comes to supporting the ways of mocking in Jest. You might have to make some changes to your tests to meet the Jest standard and spec if your tests seems to start failing.
|
||||
|
||||
Mocks that look like this are invalid, and they will throw a reference error in line with the Jest documentation [here on example 3](https://jestjs.io/docs/es6-class-mocks#calling-jestmock-with-the-module-factory-parameter)
|
||||
|
||||
```ts
|
||||
const mockCommandExists = jest.fn();
|
||||
jest.mock('command-exists', () => mockCommandExists);
|
||||
```
|
||||
|
||||
You might need to update these mocks to look a little like the following to defer the call to the `jest.fn()` spy until the mock is called.
|
||||
|
||||
```ts
|
||||
const mockCommandExists = jest.fn();
|
||||
jest.mock(
|
||||
'command-exists',
|
||||
() =>
|
||||
(...args: any[]) =>
|
||||
commandExists(...args),
|
||||
);
|
||||
```
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
import { AbortController as AbortController_2 } from 'node-abort-controller';
|
||||
import { AbortSignal as AbortSignal_2 } from 'node-abort-controller';
|
||||
import aws from 'aws-sdk';
|
||||
import { AwsS3Integration } from '@backstage/integration';
|
||||
import { AzureIntegration } from '@backstage/integration';
|
||||
import { BitbucketCloudIntegration } from '@backstage/integration';
|
||||
@@ -34,7 +35,6 @@ import { Readable } from 'stream';
|
||||
import { ReadCommitResult } from 'isomorphic-git';
|
||||
import { RequestHandler } from 'express';
|
||||
import { Router } from 'express';
|
||||
import { S3 } from 'aws-sdk';
|
||||
import { Server } from 'http';
|
||||
import * as winston from 'winston';
|
||||
import { Writable } from 'stream';
|
||||
@@ -44,7 +44,7 @@ export class AwsS3UrlReader implements UrlReader {
|
||||
constructor(
|
||||
integration: AwsS3Integration,
|
||||
deps: {
|
||||
s3: S3;
|
||||
s3: aws.S3;
|
||||
treeResponseFactory: ReadTreeResponseFactory;
|
||||
},
|
||||
);
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// note: We do the import like this so that we don't get issues destructuring
|
||||
// and it not being mocked by the aws-sdk-mock package which is unfortunate.
|
||||
import aws from 'aws-sdk';
|
||||
import { CredentialsOptions } from 'aws-sdk/lib/credentials';
|
||||
import {
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import mockAws from 'aws-sdk-mock';
|
||||
import aws from 'aws-sdk';
|
||||
import path from 'path';
|
||||
|
||||
import { getVoidLogger, UrlReaders } from '@backstage/backend-common';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { AwsS3DiscoveryProcessor } from './AwsS3DiscoveryProcessor';
|
||||
@@ -24,8 +22,12 @@ import {
|
||||
CatalogProcessorResult,
|
||||
processingResult,
|
||||
} from '@backstage/plugin-catalog-backend';
|
||||
import AWSMock from 'aws-sdk-mock';
|
||||
import aws from 'aws-sdk';
|
||||
import path from 'path';
|
||||
import YAML from 'yaml';
|
||||
|
||||
AWSMock.setSDKInstance(aws);
|
||||
const object: aws.S3.Types.Object = {
|
||||
Key: 'awsS3-mock-object.txt',
|
||||
};
|
||||
@@ -33,11 +35,8 @@ const objectList: aws.S3.ObjectList = [object];
|
||||
const output: aws.S3.Types.ListObjectsV2Output = {
|
||||
Contents: objectList,
|
||||
};
|
||||
|
||||
mockAws.setSDKInstance(require('aws-sdk'));
|
||||
|
||||
mockAws.mock('S3', 'listObjectsV2', output);
|
||||
mockAws.mock(
|
||||
AWSMock.mock('S3', 'listObjectsV2', output);
|
||||
AWSMock.mock(
|
||||
'S3',
|
||||
'getObject',
|
||||
Buffer.from(
|
||||
@@ -76,7 +75,6 @@ describe('readLocation', () => {
|
||||
},
|
||||
),
|
||||
)) as CatalogProcessorEntityResult;
|
||||
console.log(generated);
|
||||
expect(generated.type).toBe('entity');
|
||||
expect(generated.location).toEqual({
|
||||
target: 'awsS3-mock-object.txt',
|
||||
|
||||
Reference in New Issue
Block a user