-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[identity] Use esm4mocha, re-enable IBC test, remove unnecessary stub #28580
Conversation
@@ -32,7 +33,8 @@ export async function load(url, context, defaultLoad) { | |||
}; | |||
} | |||
const { source } = await defaultLoad(url, context, defaultLoad); | |||
return { format: context.format, source, shortCircuit: true }; | |||
const format = context.format ?? "builtin"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node:fs/promises wasn't importing correctly for me. I was thinking it's fine to default to builtin? Alternatively I can also do something like:
const format = context.format
if (format === undefined && url.startsWith("node:")) format = "builtin"
Or if anyone has a better suggestion, I am not too familiar with loader logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting! My changes are barely minimum to get many packages test running. I am sure there are cases that aren't handled properly. If buildin
works we will use it!
sdk/identity/identity/package.json
Outdated
@@ -55,7 +55,7 @@ | |||
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", | |||
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", | |||
"integration-test:browser": "echo skipped", | |||
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 180000 'dist-esm/test/public/node/*.spec.js' 'dist-esm/test/internal/node/*.spec.js'", | |||
"integration-test:node": "dev-tool run test:node-js-input --no-esm=true -- --loader=../../../common/tools/esm4mocha.mjs --timeout 180000 'dist-esm/test/public/node/*.spec.js' 'dist-esm/test/internal/node/*.spec.js'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identity's integration tests use the recordings as well, for <reasons>
, so we need the test proxy running. Easiest way is to keep using dev-tool commands
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I was going to add an option then switch most of our packages over to use that. Eventually also would like to make using the loader default behavior. --no-esm
doesn't sound like a great name but I haven't got a better one either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking maybe something like "loader" with a default of esm
?
Then, you could omit it for existing behavior or pass --loader=esm4mocha
for the new mocha loader. Maybe that would be nicer? I'll push that up shortly because I also don't love "no-esm" - let me know how that looks once I push the changes up!
Once we are comfortable we can make the default value esm4mocha and everyone will just get it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that --loader=
may be confusing, sounding like you could pass any strings there but they get ignored. How about --use-esm-workaround=false
with default value of true
? I think there are only a handful packages that doesn't work immediately now with the esm4mocha
loader. Once I switch majority over, I can make the default value false
then added ``--use-esm-workaround=true` to those a few packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good point and I agree with loader
being confusing... let me push up a change with your suggestion and we can see if that reads better 👍
@@ -95,7 +95,6 @@ describe("ClientAssertionCredential (internal)", function () { | |||
await credential.getToken("https://vault.azure.net/.default"); | |||
} catch (e: any) { | |||
// We're ignoring errors since our main goal here is to ensure that we send the correct parameters to MSAL. | |||
console.log("error", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds noise, if we're ignoring it let's ignore it
@@ -114,7 +114,7 @@ describe("ClientCertificateCredential (internal)", function () { | |||
}); | |||
|
|||
it("throws when given a file that doesn't contain a PEM-formatted certificate", async function (this: Context) { | |||
const fullPath = path.resolve(__dirname, "../src/index.ts"); | |||
const fullPath = path.resolve("./clientCertificateCredential.spec.ts"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__dirname is not supported, but it doesn't actually matter what file we send as long as it's not a proper cert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah __dirname is blocking some packages' test too. There's recommendation of const __dirname=path.dirname(url.fileURLToPath(import.meta.url)
but import.meta.url
requires "module" of "ES2020", which is at odds with our module of commonjs for test:node-ts-input :(
@@ -46,9 +44,6 @@ export async function msalNodeTestSetup( | |||
|
|||
const sandbox = createSandbox(); | |||
|
|||
const stub = sandbox.stub(util, "randomUUID"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a better world to live in, no weird wrapping and no concerns with immutable modules
import * as net from "net"; | ||
import * as tls from "tls"; | ||
|
||
import jwt from "jsonwebtoken"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be the default export to work
/azp run js - identity - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run js - maps-geolocation-rest - tests |
/azp run js - communication-identity - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
Azure Pipelines successfully started running 1 pipeline(s). |
API change check API changes are not detected in this pull request. |
}, | ||
); | ||
|
||
export default leafCommand(commandInfo, async (options) => { | ||
const reporterArgs = | ||
"--reporter ../../../common/tools/mocha-multi-reporter.js --reporter-option output=test-results.xml"; | ||
const defaultMochaArgs = `${ | ||
(await isModuleProject()) | ||
options["no-esm"] === true || (await isModuleProject()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking to use an option to toggle between the two workarounds, for example with --no-esm=true
and if it is not module project, we would have "--loader=../../../esm4mocha.mjs -r source-map-support/register"
so we don't have to pass the loader option in the package's NPM script.
ec62363
to
2b6207b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Packages impacted by this PR
@azure/identity
Issues associated with this PR
Describe the problem that is addressed by this PR
This PR addresses 3 things, all thanks to @jeremymeng's work on esm4mocha:
Unfortunately we are not out of the woods regarding msal-node and esm. We would need to get everyone migrated over
to this loader before we can upgrade msal-node repo-wide :(
Provide a list of related PRs (if any)
#28556
Command used to generate this PR: (Applicable only to SDK release request PRs)
Checklists