Skip to content

Commit

Permalink
fix: remove test utilities and dependency from package
Browse files Browse the repository at this point in the history
The SDK unit test helpers, which relied on test-scoped dependency "expect",
have been removed from the package. They will be exposed through a new NPM
package, separate from this one. The intention is to decouple testing
logic from production logic. This package, which is scoped for production,
will no longer contain the "expect" dependency, which has caused issues for
users. SDK projects will need to install the new package as a development
dependency and update their test code to use it instead. The functionality
will all remain the same.

This new package is still included in this project but it will not be built
and published as a part of public API. Instead, it will be isolated and
self-contained, with its own package.json, etc. For now, it will be published
manually - semantic release will only be used to automate publishing of the core.

BREAKING CHANGE: SDK test helpers are no longer exposed in this package.

To continue using the test helpers, which SDK unit tests still rely on, install
the new "@ibm-cloud/sdk-test-utilities" package as a development dependency.

Signed-off-by: Dustin Popp <dustinpopp@ibm.com>
  • Loading branch information
dpopp07 committed Jun 18, 2024
1 parent 3d8fef5 commit 901ece0
Show file tree
Hide file tree
Showing 15 changed files with 634 additions and 297 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ dist/
temp/
build/
es/tsdoc-metadata.json

# For sub-package with test utilities
!sdk-test-utilities/index.js
8 changes: 4 additions & 4 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "package-lock.json|^.secrets.baseline$",
"lines": null
},
"generated_at": "2024-04-16T16:00:48Z",
"generated_at": "2024-06-06T19:22:54Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -96,7 +96,7 @@
"hashed_secret": "bc2f74c22f98f7b6ffbc2f67453dbfa99bce9a32",
"is_secret": false,
"is_verified": false,
"line_number": 146,
"line_number": 174,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -334,7 +334,7 @@
"hashed_secret": "45c43fe97e3a06ab078b0eeff6fbe622cc417a25",
"is_secret": false,
"is_verified": false,
"line_number": 284,
"line_number": 266,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -582,7 +582,7 @@
}
]
},
"version": "0.13.1+ibm.62.dss",
"version": "0.13.1+ibm.56.dss",
"word_list": {
"file": null,
"hash": null
Expand Down
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ before_install:
- npm --version

script:
# Prepare sub-package for tests
- cd sdk-test-utilities && npm ci && cd ..

# Run standard build steps.
- npm run build
- npm run lint
- npm run test-travis
Expand Down
15 changes: 15 additions & 0 deletions MIGRATION-V5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Migration Guide for v5

## Breaking Changes

### Node Version
Node version 16 is no longer supported - 18 is the minimum version supported.

### SDK Unit Test Helpers
The formerly available helper functions exposed in this package have been removed. These
functions were intended for use in the unit tests of a generated SDK project.

The functions are now present in a new package called `@ibm-cloud/sdk-test-utilities`.
To continue using the helper functions in SDK test code, install this new package as a
development dependency and import the functions from there. The interface and functions
remain completely identical to the functions formerly exposed in this package.
30 changes: 0 additions & 30 deletions etc/ibm-cloud-sdk-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,6 @@ export function buildRequestFileObject(fileParam: FileWithMetadata): Promise<Fil
// @public
export function checkCredentials(obj: any, credsToCheck: string[]): Error | null;

// @public
function checkForSuccessfulExecution(createRequestMock: any): void;

// @public
function checkMediaHeaders(createRequestMock: any, accept: string, contentType: string): void;

// @public
function checkUrlAndMethod(options: any, url: string, method: any): void;

// @public
function checkUserHeader(createRequestMock: any, userHeaderName: string, userHeaderValue: string): void;

// @public
export class CloudPakForDataAuthenticator extends TokenRequestBasedAuthenticator {
// Warning: (ae-forgotten-export) The symbol "Options_4" needs to be exported by the entry point index.d.ts
Expand Down Expand Up @@ -176,9 +164,6 @@ export class Cp4dTokenManager extends JwtTokenManager {
protected requiredOptions: string[];
}

// @public
function expectToBePromise(sdkPromise: any): void;

// @public (undocumented)
export function fileExistsAtPath(filepath: string): boolean;

Expand Down Expand Up @@ -236,9 +221,6 @@ export function getMissingParams(params: {
// @public
export function getNewLogger(moduleName: string): SDKLogger;

// @public
function getOptions(createRequestMock: any): any;

// @public
export function getQueryParam(urlStr: string, param: string): string;

Expand Down Expand Up @@ -458,18 +440,6 @@ export class TokenRequestBasedAuthenticator extends Authenticator {
// @public
export function toLowerKeys(obj: Object): Object;

declare namespace unitTestUtils {
export {
checkUrlAndMethod,
checkMediaHeaders,
checkUserHeader,
checkForSuccessfulExecution,
getOptions,
expectToBePromise
}
}
export { unitTestUtils }

// @public
export interface UserOptions {
[propName: string]: any;
Expand Down
5 changes: 1 addition & 4 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2019, 2021.
* (C) Copyright IBM Corp. 2019, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,13 +18,10 @@
* @module ibm-cloud-sdk-core
*/

import * as unitTestUtils from './lib/sdk-test-helpers';

export { BaseService, UserOptions } from './lib/base-service';
export * from './auth';
export * from './lib/helper';
export { default as qs } from './lib/querystring';
export { default as contentType } from './lib/content-type';
export * from './lib/stream-to-promise';
export { unitTestUtils };
export { getNewLogger, SDKLogger } from './lib/get-new-logger';
34 changes: 0 additions & 34 deletions lib/sdk-test-helpers.browser.ts

This file was deleted.

Loading

0 comments on commit 901ece0

Please sign in to comment.