Skip to content

get tests running #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 6, 2025
Merged

get tests running #19

merged 11 commits into from
May 6, 2025

Conversation

ekozilforce
Copy link
Collaborator

@ekozilforce ekozilforce commented May 5, 2025

Overview

This pr fixes issues running tests locally and in ci. Smoke tested by deploying this into the applink getting started nodejs project and running InvokeHerokuAPI.getAccounts(); anonymous Apex in the related org.

To verify tests can run in CI now this pr formats the codebase to pass the format check.

In get tests running initially switched package.json to use type: "module" to use ESM, but I decided to not do that for now because it can have impact on consumers. So, went back to commonjs in fix tests but with commonjs.

Many tests were failing. I cannot find any evidence of these passing in ci (all commits in this repo fail to run any ci tests, until this pr). For now, we skip failing tests.

20 passing (2s)
93 pending

Details

Failed to pull in CI workflow:
remote: The repository owner has an IP allow list enabled, and 13.88.119.182 is not permitted to access this repository.

https://github.com/heroku/heroku-applink-nodejs/actions/runs/11602845476/job/32308657232#step:2:44

Wiremock duplicate id error

% npm run wiremock

> @heroku/salesforce-sdk-nodejs@0.3.4-ea wiremock
> wiremock --port 8080 --bind-address 127.0.0.1 --disable-banner

Exception in thread "main" com.github.tomakehurst.wiremock.common.InvalidInputException: {
  "errors" : [ {
    "code" : 109,
    "title" : "Duplicate stub mapping ID",
    "detail" : "ID of the provided stub mapping 'b843b8c1-6492-4048-90d5-08d6f90cb739' is already taken by another stub mapping"
  } ]
}
        at com.github.tomakehurst.wiremock.stubbing.AbstractStubMappings.addMapping(AbstractStubMappings.java:169)
        at com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource.loadMappingsInto(JsonFileMappingsSource.java:120)
        at com.github.tomakehurst.wiremock.core.WireMockApp.loadMappingsUsing(WireMockApp.java:288)
        at com.github.tomakehurst.wiremock.core.WireMockApp.loadDefaultMappings(WireMockApp.java:282)
        at com.github.tomakehurst.wiremock.core.WireMockApp.<init>(WireMockApp.java:143)
        at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:74)
        at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.run(WireMockServerRunner.java:71)
        at wiremock.Run.main(Run.java:23)

Mocha would not run:

yarn mocha
yarn run v1.22.22
$ mocha
(node:33819) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:33819) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:33819) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.

✖ ERROR: /Users/ekozil/Projects/heroku-applink-nodejs/test/setup.ts:8
export const mochaHooks = {
^^^^^^

SyntaxError: Unexpected token 'export'
    at wrapSafe (node:internal/modules/cjs/loader:1389:18)
    at Module._compile (node:internal/modules/cjs/loader:1425:20)
    at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
    at Module.load (node:internal/modules/cjs/loader:1287:32)
    at Module._load (node:internal/modules/cjs/loader:1103:12)
    at cjsLoader (node:internal/modules/esm/translators:318:15)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:258:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:474:24)
    at async formattedImport (/Users/ekozil/Projects/heroku-applink-nodejs/node_modules/mocha/lib/nodejs/esm-utils.js:9:14)
    at async exports.requireOrImport (/Users/ekozil/Projects/heroku-applink-nodejs/node_modules/mocha/lib/nodejs/esm-utils.js:42:28)
    at async exports.handleRequires (/Users/ekozil/Projects/heroku-applink-nodejs/node_modules/mocha/lib/cli/run-helpers.js:95:28)
    at async /Users/ekozil/Projects/heroku-applink-nodejs/node_modules/mocha/lib/cli/run.js:354:25
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Comment on lines +16 to +17
os:
[sfdc-hk-ubuntu-latest, sfdc-hk-macos-latest, sfdc-hk-windows-latest]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes issue with pulling from github repo

Comment on lines -4 to +6
"loader": "ts-node/esm",
"loader": "ts-node",
"recursive": true,
"require": ["test/setup.ts"],
"require": ["ts-node/register", "test/setup.ts"],
Copy link
Collaborator Author

@ekozilforce ekozilforce May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our tests use esm loader but our codebase is configured for commonjs per package.json 🤔 . To get tests running I found paths either using type: module in package.json with esm, or using ts-node with commonjs and the default type.

@ekozilforce ekozilforce marked this pull request as ready for review May 5, 2025 17:48
{
"extends": "./tsconfig.json",
"ts-node": {
"transpileOnly": true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like typechecking my tests, but it takes time to get there in existing codebases. For now, let's only transpile.

@ekozilforce ekozilforce force-pushed the ekozil/get-tests-running branch from 6330287 to 9de1b57 Compare May 5, 2025 20:18
@ekozilforce ekozilforce force-pushed the ekozil/get-tests-running branch from 9de1b57 to be6fb45 Compare May 5, 2025 20:19
@@ -12,8 +12,9 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [22, 20, 18, 16, 14]
os: [windows-latest, macos-latest-large, ubuntu-latest]
version: [22, 20, 18]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

16 and 14 have been eol for ~years: https://nodejs.org/en/about/previous-releases

@ekozilforce ekozilforce requested review from cwallsfdc and gsinghsfdc and removed request for cwallsfdc May 5, 2025 20:29
@ekozilforce ekozilforce merged commit 004b4b9 into main May 6, 2025
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants