@depup/dd-trace 5.97.0-depup.0 → 6.4.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-3rdparty.csv +89 -104
- package/README.md +9 -3
- package/changes.json +8 -3
- package/ci/init.js +25 -5
- package/ci/vitest-no-worker-init-setup.mjs +430 -0
- package/ext/exporters.js +1 -0
- package/ext/tags.js +3 -0
- package/index.d.ts +315 -244
- package/index.electron.js +3 -0
- package/initialize.mjs +9 -8
- package/loader-hook.mjs +154 -47
- package/package.json +118 -78
- package/packages/datadog-core/src/storage.js +47 -48
- package/packages/datadog-esbuild/index.js +32 -1
- package/packages/datadog-esbuild/src/utils.js +46 -3
- package/packages/datadog-instrumentations/src/aerospike.js +3 -3
- package/packages/datadog-instrumentations/src/ai.js +131 -76
- package/packages/datadog-instrumentations/src/amqplib.js +6 -7
- package/packages/datadog-instrumentations/src/anthropic.js +10 -10
- package/packages/datadog-instrumentations/src/apollo-server-core.js +3 -3
- package/packages/datadog-instrumentations/src/apollo-server.js +10 -18
- package/packages/datadog-instrumentations/src/avsc.js +6 -6
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js-context-methods.js +18 -0
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +111 -0
- package/packages/datadog-instrumentations/src/aws-sdk.js +172 -72
- package/packages/datadog-instrumentations/src/azure-cosmos.js +7 -0
- package/packages/datadog-instrumentations/src/azure-durable-functions.js +8 -8
- package/packages/datadog-instrumentations/src/azure-functions.js +3 -0
- package/packages/datadog-instrumentations/src/bluebird.js +2 -2
- package/packages/datadog-instrumentations/src/body-parser.js +5 -2
- package/packages/datadog-instrumentations/src/cassandra-driver.js +12 -9
- package/packages/datadog-instrumentations/src/child_process.js +15 -15
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +587 -0
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +41 -24
- package/packages/datadog-instrumentations/src/connect.js +14 -12
- package/packages/datadog-instrumentations/src/cookie-parser.js +5 -4
- package/packages/datadog-instrumentations/src/cookie.js +9 -3
- package/packages/datadog-instrumentations/src/couchbase.js +73 -238
- package/packages/datadog-instrumentations/src/crypto.js +49 -4
- package/packages/datadog-instrumentations/src/cucumber-worker-threads.js +19 -0
- package/packages/datadog-instrumentations/src/cucumber.js +747 -187
- package/packages/datadog-instrumentations/src/cypress-config.js +164 -56
- package/packages/datadog-instrumentations/src/cypress.js +5 -3
- package/packages/datadog-instrumentations/src/dns.js +60 -59
- package/packages/datadog-instrumentations/src/elasticsearch.js +9 -12
- package/packages/datadog-instrumentations/src/electron/preload.js +42 -0
- package/packages/datadog-instrumentations/src/electron.js +240 -0
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +11 -9
- package/packages/datadog-instrumentations/src/express-session.js +14 -13
- package/packages/datadog-instrumentations/src/express.js +52 -30
- package/packages/datadog-instrumentations/src/fastify.js +169 -86
- package/packages/datadog-instrumentations/src/fetch.js +5 -5
- package/packages/datadog-instrumentations/src/fs.js +22 -20
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +5 -7
- package/packages/datadog-instrumentations/src/google-genai.js +4 -4
- package/packages/datadog-instrumentations/src/graphql.js +26 -362
- package/packages/datadog-instrumentations/src/grpc/client.js +48 -32
- package/packages/datadog-instrumentations/src/grpc/server.js +20 -2
- package/packages/datadog-instrumentations/src/hapi.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +74 -0
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +85 -9
- package/packages/datadog-instrumentations/src/helpers/hook.js +4 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +36 -3
- package/packages/datadog-instrumentations/src/helpers/kafka.js +58 -0
- package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +65 -0
- package/packages/datadog-instrumentations/src/helpers/promise-instrumentor.js +42 -0
- package/packages/datadog-instrumentations/src/helpers/promise.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +7 -5
- package/packages/datadog-instrumentations/src/helpers/require-optional-peer.js +17 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +13 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +24 -7
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +6 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/aws-durable-execution-sdk-js.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/azure-cosmos.js +50 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/claude-agent-sdk.js +17 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +201 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +7 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langgraph.js +4 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/mercurius.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-sdk.js +35 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +85 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +18 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +49 -224
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +8 -8
- package/packages/datadog-instrumentations/src/hono.js +71 -9
- package/packages/datadog-instrumentations/src/http/client.js +48 -24
- package/packages/datadog-instrumentations/src/http/server.js +75 -29
- package/packages/datadog-instrumentations/src/http2/client.js +15 -12
- package/packages/datadog-instrumentations/src/http2/server.js +156 -23
- package/packages/datadog-instrumentations/src/ioredis.js +17 -14
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -2
- package/packages/datadog-instrumentations/src/jest/bail-reporter.js +42 -0
- package/packages/datadog-instrumentations/src/jest/coverage-backfill.js +163 -0
- package/packages/datadog-instrumentations/src/jest.js +1783 -401
- package/packages/datadog-instrumentations/src/kafkajs.js +284 -170
- package/packages/datadog-instrumentations/src/knex.js +17 -17
- package/packages/datadog-instrumentations/src/koa.js +15 -14
- package/packages/datadog-instrumentations/src/ldapjs.js +5 -5
- package/packages/datadog-instrumentations/src/light-my-request.js +2 -2
- package/packages/datadog-instrumentations/src/limitd-client.js +4 -4
- package/packages/datadog-instrumentations/src/lodash.js +4 -4
- package/packages/datadog-instrumentations/src/mariadb.js +18 -16
- package/packages/datadog-instrumentations/src/memcached.js +4 -3
- package/packages/datadog-instrumentations/src/mercurius.js +11 -0
- package/packages/datadog-instrumentations/src/microgateway-core.js +2 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +7 -4
- package/packages/datadog-instrumentations/src/mocha/main.js +557 -118
- package/packages/datadog-instrumentations/src/mocha/utils.js +531 -131
- package/packages/datadog-instrumentations/src/mocha/worker.js +27 -9
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +254 -0
- package/packages/datadog-instrumentations/src/mongodb-core.js +43 -31
- package/packages/datadog-instrumentations/src/mongodb.js +79 -5
- package/packages/datadog-instrumentations/src/mongoose.js +43 -34
- package/packages/datadog-instrumentations/src/mquery.js +5 -5
- package/packages/datadog-instrumentations/src/multer.js +5 -4
- package/packages/datadog-instrumentations/src/mysql.js +17 -17
- package/packages/datadog-instrumentations/src/mysql2.js +39 -5
- package/packages/datadog-instrumentations/src/nats.js +182 -0
- package/packages/datadog-instrumentations/src/net.js +19 -11
- package/packages/datadog-instrumentations/src/next.js +44 -10
- package/packages/datadog-instrumentations/src/nyc.js +43 -6
- package/packages/datadog-instrumentations/src/openai.js +124 -38
- package/packages/datadog-instrumentations/src/oracledb.js +12 -7
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +27 -6
- package/packages/datadog-instrumentations/src/passport-utils.js +5 -5
- package/packages/datadog-instrumentations/src/path-to-regexp.js +44 -0
- package/packages/datadog-instrumentations/src/pg.js +58 -25
- package/packages/datadog-instrumentations/src/pino.js +25 -41
- package/packages/datadog-instrumentations/src/playwright-browser-scripts.js +27 -0
- package/packages/datadog-instrumentations/src/playwright.js +1086 -350
- package/packages/datadog-instrumentations/src/protobufjs.js +16 -16
- package/packages/datadog-instrumentations/src/redis.js +28 -15
- package/packages/datadog-instrumentations/src/restify.js +6 -5
- package/packages/datadog-instrumentations/src/router.js +243 -87
- package/packages/datadog-instrumentations/src/selenium.js +1 -2
- package/packages/datadog-instrumentations/src/stripe.js +47 -33
- package/packages/datadog-instrumentations/src/tedious.js +28 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1297 -0
- package/packages/datadog-instrumentations/src/vitest-main.js +1592 -0
- package/packages/datadog-instrumentations/src/vitest-util.js +251 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +822 -0
- package/packages/datadog-instrumentations/src/vitest.js +11 -1262
- package/packages/datadog-instrumentations/src/winston.js +4 -4
- package/packages/datadog-instrumentations/src/ws.js +7 -7
- package/packages/datadog-instrumentations/src/zlib.js +29 -0
- package/packages/datadog-plugin-ai/src/index.js +1 -1
- package/packages/datadog-plugin-ai/src/tracing.js +66 -3
- package/packages/datadog-plugin-ai/src/utils.js +17 -4
- package/packages/datadog-plugin-apollo/src/gateway/request.js +1 -21
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/checkpoint.js +31 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/client.js +55 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js +123 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js +129 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/index.js +19 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +224 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +79 -0
- package/packages/datadog-plugin-aws-sdk/src/base.js +86 -50
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +218 -4
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +59 -14
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +174 -75
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +34 -23
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +26 -26
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +187 -101
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +20 -18
- package/packages/datadog-plugin-azure-cosmos/src/index.js +144 -0
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +8 -15
- package/packages/datadog-plugin-azure-functions/src/index.js +7 -3
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +5 -10
- package/packages/datadog-plugin-bullmq/src/consumer.js +5 -4
- package/packages/datadog-plugin-bullmq/src/filter.js +35 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +121 -33
- package/packages/datadog-plugin-bunyan/src/index.js +28 -0
- package/packages/datadog-plugin-child_process/src/index.js +13 -2
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -6
- package/packages/datadog-plugin-claude-agent-sdk/src/index.js +31 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/tracing.js +107 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/util.js +15 -0
- package/packages/datadog-plugin-couchbase/src/index.js +58 -52
- package/packages/datadog-plugin-cucumber/src/index.js +46 -28
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +961 -92
- package/packages/datadog-plugin-cypress/src/index.js +104 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +6 -14
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +48 -1
- package/packages/datadog-plugin-cypress/src/support.js +180 -25
- package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup.js +8 -6
- package/packages/datadog-plugin-elasticsearch/src/index.js +28 -8
- package/packages/datadog-plugin-electron/src/index.js +17 -0
- package/packages/datadog-plugin-electron/src/ipc.js +143 -0
- package/packages/datadog-plugin-electron/src/net.js +82 -0
- package/packages/datadog-plugin-express/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fastify/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fs/src/index.js +2 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +27 -18
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +5 -8
- package/packages/datadog-plugin-graphql/src/execute.js +706 -34
- package/packages/datadog-plugin-graphql/src/index.js +43 -9
- package/packages/datadog-plugin-graphql/src/parse.js +45 -4
- package/packages/datadog-plugin-graphql/src/request.js +135 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +32 -7
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +118 -100
- package/packages/datadog-plugin-graphql/src/utils.js +261 -3
- package/packages/datadog-plugin-graphql/src/validate.js +53 -7
- package/packages/datadog-plugin-grpc/src/client.js +7 -8
- package/packages/datadog-plugin-grpc/src/server.js +1 -1
- package/packages/datadog-plugin-grpc/src/util.js +57 -22
- package/packages/datadog-plugin-http/src/client.js +12 -14
- package/packages/datadog-plugin-http/src/index.js +6 -8
- package/packages/datadog-plugin-http/src/server.js +63 -20
- package/packages/datadog-plugin-http2/src/client.js +6 -3
- package/packages/datadog-plugin-http2/src/server.js +48 -8
- package/packages/datadog-plugin-jest/src/index.js +133 -67
- package/packages/datadog-plugin-jest/src/util.js +37 -16
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -9
- package/packages/datadog-plugin-kafkajs/src/producer.js +37 -8
- package/packages/datadog-plugin-langgraph/src/stream.js +1 -1
- package/packages/datadog-plugin-memcached/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +66 -20
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/index.js +24 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +173 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +30 -0
- package/packages/datadog-plugin-mongodb-core/src/bulk-write.js +43 -0
- package/packages/datadog-plugin-mongodb-core/src/index.js +8 -206
- package/packages/datadog-plugin-mongodb-core/src/query.js +452 -0
- package/packages/datadog-plugin-mysql/src/index.js +9 -4
- package/packages/datadog-plugin-nats/src/consumer.js +43 -0
- package/packages/datadog-plugin-nats/src/index.js +20 -0
- package/packages/datadog-plugin-nats/src/producer.js +62 -0
- package/packages/datadog-plugin-nats/src/util.js +33 -0
- package/packages/datadog-plugin-next/src/index.js +12 -4
- package/packages/datadog-plugin-openai/src/services.js +4 -3
- package/packages/datadog-plugin-openai/src/tracing.js +27 -25
- package/packages/datadog-plugin-oracledb/src/index.js +13 -2
- package/packages/datadog-plugin-pg/src/index.js +13 -3
- package/packages/datadog-plugin-pino/src/index.js +42 -0
- package/packages/datadog-plugin-playwright/src/index.js +21 -11
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-redis/src/index.js +54 -25
- package/packages/datadog-plugin-rhea/src/producer.js +1 -1
- package/packages/datadog-plugin-router/src/index.js +46 -44
- package/packages/datadog-plugin-selenium/src/index.js +1 -1
- package/packages/datadog-plugin-tedious/src/index.js +1 -1
- package/packages/datadog-plugin-undici/src/index.js +24 -2
- package/packages/datadog-plugin-vitest/src/index.js +160 -90
- package/packages/datadog-plugin-winston/src/index.js +30 -0
- package/packages/datadog-plugin-ws/src/close.js +3 -1
- package/packages/datadog-plugin-ws/src/producer.js +2 -0
- package/packages/datadog-plugin-ws/src/receiver.js +2 -1
- package/packages/datadog-shimmer/src/shimmer.js +101 -39
- package/packages/datadog-webpack/index.js +17 -1
- package/packages/datadog-webpack/src/optional-peer-loader.js +17 -0
- package/packages/dd-trace/index.electron.js +3 -0
- package/packages/dd-trace/index.js +2 -36
- package/packages/dd-trace/src/aiguard/channels.js +7 -0
- package/packages/dd-trace/src/aiguard/index.js +16 -34
- package/packages/dd-trace/src/aiguard/integrations/evaluate.js +46 -0
- package/packages/dd-trace/src/aiguard/integrations/index.js +34 -0
- package/packages/dd-trace/src/aiguard/integrations/openai.js +80 -0
- package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +92 -0
- package/packages/dd-trace/src/aiguard/messages/openai.js +382 -0
- package/packages/{datadog-instrumentations/src/helpers/ai-messages.js → dd-trace/src/aiguard/messages/vercel-ai.js} +30 -27
- package/packages/dd-trace/src/aiguard/sdk.js +147 -54
- package/packages/dd-trace/src/aiguard/tags.js +26 -10
- package/packages/dd-trace/src/appsec/api_security/index.js +55 -0
- package/packages/dd-trace/src/appsec/api_security/sampler.js +147 -0
- package/packages/dd-trace/src/appsec/blocked_templates.js +4 -3
- package/packages/dd-trace/src/appsec/blocking.js +82 -42
- package/packages/dd-trace/src/appsec/channels.js +5 -1
- package/packages/dd-trace/src/appsec/downstream_requests.js +116 -62
- package/packages/dd-trace/src/appsec/graphql.js +20 -17
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +81 -81
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +23 -23
- package/packages/dd-trace/src/appsec/iast/index.js +3 -2
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/telemetry/index.js +2 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +54 -12
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +5 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +31 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +83 -48
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +1 -1
- package/packages/dd-trace/src/appsec/index.js +65 -47
- package/packages/dd-trace/src/appsec/lambda.js +135 -0
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -5
- package/packages/dd-trace/src/appsec/rasp/lfi.js +8 -4
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +5 -10
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +26 -18
- package/packages/dd-trace/src/appsec/recommended.json +2438 -13
- package/packages/dd-trace/src/appsec/reporter.js +87 -28
- package/packages/dd-trace/src/appsec/rule_manager.js +4 -2
- package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/track_event.js +5 -5
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +7 -11
- package/packages/dd-trace/src/appsec/sdk/utils.js +5 -3
- package/packages/dd-trace/src/appsec/store.js +50 -0
- package/packages/dd-trace/src/appsec/telemetry/api_security.js +34 -0
- package/packages/dd-trace/src/appsec/telemetry/index.js +27 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +5 -4
- package/packages/dd-trace/src/appsec/waf/index.js +19 -9
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +35 -20
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
- package/packages/dd-trace/src/azure_metadata.js +17 -6
- package/packages/dd-trace/src/baggage.js +32 -13
- package/packages/dd-trace/src/bootstrap.js +39 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +30 -5
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +122 -24
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +22 -7
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +5 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +6 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +148 -25
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -4
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +28 -10
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +22 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +105 -22
- package/packages/dd-trace/src/ci-visibility/lage.js +2 -1
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +73 -55
- package/packages/dd-trace/src/ci-visibility/requests/request.js +14 -50
- package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +4 -4
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +156 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +5 -3
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +24 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +70 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +128 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +291 -0
- package/packages/dd-trace/src/config/config-types.d.ts +8 -6
- package/packages/dd-trace/src/config/defaults.js +71 -44
- package/packages/dd-trace/src/config/generated-config-types.d.ts +676 -131
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/config/helper.js +139 -33
- package/packages/dd-trace/src/config/index.js +117 -131
- package/packages/dd-trace/src/config/major-overrides.js +100 -0
- package/packages/dd-trace/src/config/normalize-service.js +31 -0
- package/packages/dd-trace/src/config/parsers.js +138 -10
- package/packages/dd-trace/src/config/remote_config.js +1 -1
- package/packages/dd-trace/src/config/supported-configurations.json +394 -203
- package/packages/dd-trace/src/constants.js +15 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +18 -6
- package/packages/dd-trace/src/datastreams/checkpointer.js +6 -12
- package/packages/dd-trace/src/datastreams/context.js +4 -2
- package/packages/dd-trace/src/datastreams/encoding.js +39 -28
- package/packages/dd-trace/src/datastreams/index.js +2 -1
- package/packages/dd-trace/src/datastreams/manager.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +35 -30
- package/packages/dd-trace/src/datastreams/processor.js +31 -22
- package/packages/dd-trace/src/datastreams/size.js +6 -2
- package/packages/dd-trace/src/datastreams/writer.js +15 -6
- package/packages/dd-trace/src/debugger/config.js +9 -4
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +49 -35
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -8
- package/packages/dd-trace/src/debugger/devtools_client/config.js +3 -2
- package/packages/dd-trace/src/debugger/devtools_client/index.js +33 -71
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +83 -0
- package/packages/dd-trace/src/debugger/devtools_client/send.js +27 -6
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +2 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +5 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/index.js +13 -9
- package/packages/dd-trace/src/debugger/probe_sampler.js +112 -0
- package/packages/dd-trace/src/debugger/probe_sampler_constants.js +19 -0
- package/packages/dd-trace/src/dogstatsd.js +34 -28
- package/packages/dd-trace/src/encode/0.4.js +829 -268
- package/packages/dd-trace/src/encode/0.5.js +158 -22
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +141 -65
- package/packages/dd-trace/src/encode/agentless-json.js +12 -6
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +52 -15
- package/packages/dd-trace/src/encode/span-stats.js +19 -16
- package/packages/dd-trace/src/encode/tags-processors.js +30 -25
- package/packages/dd-trace/src/exporter.js +3 -1
- package/packages/dd-trace/src/exporters/agent/index.js +4 -5
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -2
- package/packages/dd-trace/src/exporters/agentless/index.js +12 -13
- package/packages/dd-trace/src/exporters/agentless/intake.js +43 -0
- package/packages/dd-trace/src/exporters/agentless/writer.js +12 -11
- package/packages/dd-trace/src/exporters/common/agents.js +3 -1
- package/packages/dd-trace/src/exporters/common/buffering-exporter.js +3 -3
- package/packages/dd-trace/src/exporters/common/request.js +48 -28
- package/packages/dd-trace/src/exporters/common/retry.js +104 -0
- package/packages/dd-trace/src/exporters/common/url.js +34 -0
- package/packages/dd-trace/src/exporters/common/util.js +2 -2
- package/packages/dd-trace/src/exporters/common/writer.js +17 -1
- package/packages/dd-trace/src/exporters/electron/index.js +49 -0
- package/packages/dd-trace/src/exporters/span-stats/index.js +1 -2
- package/packages/dd-trace/src/exporters/span-stats/writer.js +1 -3
- package/packages/dd-trace/src/external-logger/src/index.js +2 -1
- package/packages/dd-trace/src/feature-registry.js +22 -0
- package/packages/dd-trace/src/git_metadata.js +68 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +13 -5
- package/packages/dd-trace/src/guardrails/index.js +11 -6
- package/packages/dd-trace/src/guardrails/telemetry.js +40 -3
- package/packages/dd-trace/src/heap_snapshots.js +4 -4
- package/packages/dd-trace/src/id.js +46 -27
- package/packages/dd-trace/src/index.js +7 -8
- package/packages/dd-trace/src/lambda/handler-paths.js +52 -0
- package/packages/dd-trace/src/lambda/handler.js +2 -6
- package/packages/dd-trace/src/lambda/index.js +62 -14
- package/packages/dd-trace/src/lambda/runtime/patch.js +21 -46
- package/packages/dd-trace/src/llmobs/constants/tags.js +13 -0
- package/packages/dd-trace/src/llmobs/index.js +37 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/ddTelemetry.js +403 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +8 -395
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +119 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/vercelTelemetry.js +363 -0
- package/packages/dd-trace/src/llmobs/plugins/{anthropic.js → anthropic/index.js} +32 -79
- package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +109 -0
- package/packages/dd-trace/src/llmobs/plugins/base.js +4 -4
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +89 -37
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +270 -0
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/utils.js +10 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +5 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +81 -16
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +1 -50
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +14 -8
- package/packages/dd-trace/src/llmobs/plugins/langchain/messages.js +76 -0
- package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +3 -28
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +68 -0
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +57 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +21 -51
- package/packages/dd-trace/src/llmobs/sdk.js +56 -35
- package/packages/dd-trace/src/llmobs/span_processor.js +90 -11
- package/packages/dd-trace/src/llmobs/tagger.js +129 -4
- package/packages/dd-trace/src/llmobs/telemetry.js +31 -1
- package/packages/dd-trace/src/llmobs/util.js +202 -9
- package/packages/dd-trace/src/llmobs/writers/base.js +11 -5
- package/packages/dd-trace/src/llmobs/writers/spans.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -2
- package/packages/dd-trace/src/log/index.js +19 -31
- package/packages/dd-trace/src/log/writer.js +3 -1
- package/packages/dd-trace/src/msgpack/chunk.js +430 -11
- package/packages/dd-trace/src/msgpack/index.js +101 -2
- package/packages/dd-trace/src/noop/proxy.js +5 -4
- package/packages/dd-trace/src/noop/span.js +3 -1
- package/packages/dd-trace/src/openfeature/encoding.js +70 -0
- package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +103 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +26 -1
- package/packages/dd-trace/src/openfeature/noop.js +40 -36
- package/packages/dd-trace/src/openfeature/register.js +46 -0
- package/packages/dd-trace/src/openfeature/remote_config.js +6 -1
- package/packages/dd-trace/src/openfeature/span-enrichment-hook.js +143 -0
- package/packages/dd-trace/src/openfeature/span-enrichment.js +149 -0
- package/packages/dd-trace/src/openfeature/writers/base.js +3 -11
- package/packages/dd-trace/src/openfeature/writers/exposures.js +82 -70
- package/packages/dd-trace/src/openfeature/writers/util.js +1 -2
- package/packages/dd-trace/src/opentelemetry/active-span-proxy.js +42 -0
- package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +107 -0
- package/packages/dd-trace/src/opentelemetry/context_manager.js +27 -13
- package/packages/dd-trace/src/opentelemetry/logs/index.js +6 -6
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +61 -12
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +28 -14
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +7 -10
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +40 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +169 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +99 -5
- package/packages/dd-trace/src/opentelemetry/metrics/time.js +19 -0
- package/packages/dd-trace/src/opentelemetry/otlp/common.proto +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/logs.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/logs_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +56 -82
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +14 -2
- package/packages/dd-trace/src/opentelemetry/otlp/trace.proto +358 -0
- package/packages/dd-trace/src/opentelemetry/otlp/trace_service.proto +78 -0
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +325 -0
- package/packages/dd-trace/src/opentelemetry/span.js +59 -109
- package/packages/dd-trace/src/opentelemetry/span_context.js +1 -0
- package/packages/dd-trace/src/opentelemetry/span_processor.js +7 -5
- package/packages/dd-trace/src/opentelemetry/trace/index.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +375 -0
- package/packages/dd-trace/src/opentelemetry/tracer.js +20 -69
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +33 -17
- package/packages/dd-trace/src/opentracing/propagation/log.js +28 -8
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +278 -148
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +11 -11
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +98 -32
- package/packages/dd-trace/src/opentracing/span.js +127 -73
- package/packages/dd-trace/src/opentracing/span_context.js +68 -3
- package/packages/dd-trace/src/opentracing/tracer.js +46 -19
- package/packages/dd-trace/src/payload-tagging/config/index.js +2 -2
- package/packages/dd-trace/src/plugin_manager.js +36 -14
- package/packages/dd-trace/src/plugins/apollo.js +3 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +387 -85
- package/packages/dd-trace/src/plugins/database.js +61 -18
- package/packages/dd-trace/src/plugins/index.js +14 -0
- package/packages/dd-trace/src/plugins/log_injection.js +56 -0
- package/packages/dd-trace/src/plugins/log_plugin.js +4 -44
- package/packages/dd-trace/src/plugins/outbound.js +1 -1
- package/packages/dd-trace/src/plugins/plugin.js +19 -28
- package/packages/dd-trace/src/plugins/storage.js +2 -2
- package/packages/dd-trace/src/plugins/tracing.js +70 -13
- package/packages/dd-trace/src/plugins/util/ci.js +127 -40
- package/packages/dd-trace/src/plugins/util/git-cache.js +23 -23
- package/packages/dd-trace/src/plugins/util/git.js +3 -1
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +276 -0
- package/packages/dd-trace/src/plugins/util/llm.js +6 -1
- package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -2
- package/packages/dd-trace/src/plugins/util/test.js +894 -65
- package/packages/dd-trace/src/plugins/util/url.js +71 -5
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +18 -16
- package/packages/dd-trace/src/plugins/util/web.js +116 -180
- package/packages/dd-trace/src/priority_sampler.js +12 -21
- package/packages/dd-trace/src/profiling/config.js +132 -212
- package/packages/dd-trace/src/profiling/constants.js +4 -7
- package/packages/dd-trace/src/profiling/exporter_cli.js +10 -10
- package/packages/dd-trace/src/profiling/exporters/agent.js +61 -28
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +45 -14
- package/packages/dd-trace/src/profiling/exporters/file.js +16 -5
- package/packages/dd-trace/src/profiling/oom.js +71 -0
- package/packages/dd-trace/src/profiling/profiler.js +84 -105
- package/packages/dd-trace/src/profiling/profilers/event_plugins/crypto.js +32 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/zlib.js +19 -0
- package/packages/dd-trace/src/profiling/profilers/events.js +57 -13
- package/packages/dd-trace/src/profiling/profilers/space.js +27 -16
- package/packages/dd-trace/src/profiling/profilers/wall.js +49 -35
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -3
- package/packages/dd-trace/src/propagation-hash/index.js +1 -1
- package/packages/dd-trace/src/proxy.js +50 -36
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/index.js +6 -5
- package/packages/dd-trace/src/remote_config/scheduler.js +1 -1
- package/packages/dd-trace/src/ritm.js +6 -3
- package/packages/dd-trace/src/runtime_metrics/client.js +30 -0
- package/packages/dd-trace/src/runtime_metrics/index.js +14 -4
- package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +284 -0
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +42 -41
- package/packages/dd-trace/src/sampling_rule.js +7 -7
- package/packages/dd-trace/src/scope.js +10 -15
- package/packages/dd-trace/src/serverless.js +6 -7
- package/packages/dd-trace/src/service-naming/extra-services.js +14 -0
- package/packages/dd-trace/src/service-naming/index.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -1
- package/packages/dd-trace/src/service-naming/schemas/util.js +48 -3
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +6 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +61 -2
- package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +60 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +25 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +5 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +32 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +17 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +23 -3
- package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +6 -0
- package/packages/dd-trace/src/service-naming/source-resolver.js +50 -0
- package/packages/dd-trace/src/span_format.js +269 -81
- package/packages/dd-trace/src/span_processor.js +13 -13
- package/packages/dd-trace/src/span_stats.js +101 -79
- package/packages/dd-trace/src/spanleak.js +1 -2
- package/packages/dd-trace/src/standalone/index.js +3 -25
- package/packages/dd-trace/src/startup-log.js +3 -3
- package/packages/dd-trace/src/tagger.js +2 -4
- package/packages/dd-trace/src/telemetry/dependencies.js +2 -2
- package/packages/dd-trace/src/telemetry/endpoints.js +7 -5
- package/packages/dd-trace/src/telemetry/index.js +2 -2
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/send-data.js +20 -20
- package/packages/dd-trace/src/telemetry/session-propagation.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +16 -14
- package/packages/dd-trace/src/tracer.js +23 -9
- package/packages/dd-trace/src/tracer_metadata.js +1 -1
- package/packages/dd-trace/src/util.js +31 -0
- package/register.js +58 -1
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +94 -42
- package/vendor/dist/@datadog/sketches-js/LICENSE +10 -36
- package/vendor/dist/@datadog/sketches-js/index.js +1 -1
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/index.js +1 -1
- package/vendor/dist/protobufjs/minimal/index.js +1 -1
- package/vendor/dist/shell-quote/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +0 -178
- package/packages/dd-trace/src/agent/url.js +0 -28
- package/packages/dd-trace/src/appsec/api_security_sampler.js +0 -117
- package/packages/dd-trace/src/lambda/runtime/ritm.js +0 -133
- package/packages/dd-trace/src/log/utils.js +0 -16
- package/packages/dd-trace/src/msgpack/encoder.js +0 -308
- package/packages/dd-trace/src/plugins/structured_log_plugin.js +0 -9
- package/scripts/preinstall.js +0 -34
- package/vendor/dist/ignore/LICENSE +0 -21
- package/vendor/dist/ignore/index.js +0 -1
- package/vendor/dist/opentracing/LICENSE +0 -201
- package/vendor/dist/opentracing/binary_carrier.d.ts +0 -11
- package/vendor/dist/opentracing/constants.d.ts +0 -61
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +0 -2
- package/vendor/dist/opentracing/ext/tags.d.ts +0 -90
- package/vendor/dist/opentracing/functions.d.ts +0 -20
- package/vendor/dist/opentracing/global_tracer.d.ts +0 -14
- package/vendor/dist/opentracing/index.d.ts +0 -12
- package/vendor/dist/opentracing/index.js +0 -1
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +0 -5
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +0 -13
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +0 -16
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +0 -50
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +0 -26
- package/vendor/dist/opentracing/noop.d.ts +0 -8
- package/vendor/dist/opentracing/reference.d.ts +0 -33
- package/vendor/dist/opentracing/span.d.ts +0 -147
- package/vendor/dist/opentracing/span_context.d.ts +0 -26
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +0 -16
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +0 -3
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +0 -4
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +0 -3
- package/vendor/dist/opentracing/test/unittest.d.ts +0 -2
- package/vendor/dist/opentracing/tracer.d.ts +0 -127
- package/vendor/dist/path-to-regexp/LICENSE +0 -21
- package/vendor/dist/path-to-regexp/index.js +0 -1
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { createCoverageMap } = require('../../../../vendor/dist/istanbul-lib-coverage')
|
|
4
|
+
const satisfies = require('../../../../vendor/dist/semifies')
|
|
5
|
+
const { DD_MAJOR } = require('../../../../version')
|
|
4
6
|
const { addHook, channel } = require('../helpers/instrument')
|
|
5
7
|
const shimmer = require('../../../datadog-shimmer')
|
|
6
8
|
const { isMarkedAsUnskippable } = require('../../../datadog-plugin-jest/src/util')
|
|
9
|
+
const { writeCoverageBackfillToCache } = require('../../../dd-trace/src/ci-visibility/test-optimization-cache')
|
|
7
10
|
const log = require('../../../dd-trace/src/log')
|
|
8
11
|
const { getEnvironmentVariable } = require('../../../dd-trace/src/config/helper')
|
|
9
12
|
const {
|
|
10
13
|
getTestSuitePath,
|
|
11
14
|
MOCHA_WORKER_TRACE_PAYLOAD_CODE,
|
|
12
15
|
fromCoverageMapToCoverage,
|
|
13
|
-
|
|
16
|
+
getCoveredFilesFromCoverage,
|
|
17
|
+
getExecutableFilesFromCoverage,
|
|
18
|
+
applySkippedCoverageToCoverage,
|
|
14
19
|
mergeCoverage,
|
|
15
20
|
resetCoverage,
|
|
16
21
|
getIsFaultyEarlyFlakeDetection,
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
getRelativeCoverageFiles,
|
|
23
|
+
getTestCoverageLinesPercentage,
|
|
24
|
+
collectTestOptimizationSummariesFromTraces,
|
|
25
|
+
logTestOptimizationSummary,
|
|
26
|
+
getTestOptimizationRequestResults,
|
|
27
|
+
isModifiedTest,
|
|
19
28
|
} = require('../../../dd-trace/src/plugins/util/test')
|
|
20
29
|
|
|
21
30
|
const {
|
|
@@ -27,26 +36,33 @@ const {
|
|
|
27
36
|
getOnTestEndHandler,
|
|
28
37
|
getOnTestRetryHandler,
|
|
29
38
|
getOnHookEndHandler,
|
|
39
|
+
patchFailedTestReplayHookUp,
|
|
30
40
|
getOnFailHandler,
|
|
31
41
|
getOnPendingHandler,
|
|
32
42
|
testFileToSuiteCtx,
|
|
33
43
|
newTests,
|
|
44
|
+
efdTests,
|
|
34
45
|
testsQuarantined,
|
|
35
46
|
getTestFullName,
|
|
36
47
|
getRunTestsWrapper,
|
|
37
|
-
testsAttemptToFix,
|
|
38
|
-
testsStatuses,
|
|
39
48
|
newTestsWithDynamicNames,
|
|
49
|
+
attemptToFixExecutions,
|
|
50
|
+
loggedAttemptToFixTests,
|
|
40
51
|
} = require('./utils')
|
|
41
52
|
|
|
42
53
|
require('./common')
|
|
43
54
|
|
|
55
|
+
const MINIMUM_MOCHA_VERSION = DD_MAJOR >= 6 ? '>=8.0.0' : '>=5.2.0'
|
|
56
|
+
|
|
44
57
|
const patched = new WeakSet()
|
|
58
|
+
let hasWarnedDeprecatedMochaVersion = false
|
|
45
59
|
|
|
46
60
|
const unskippableSuites = []
|
|
47
61
|
let suitesToSkip = []
|
|
48
62
|
let isSuitesSkipped = false
|
|
49
63
|
let skippedSuites = []
|
|
64
|
+
let skippableSuitesCoverage = {}
|
|
65
|
+
let skippedSuitesCoverage = {}
|
|
50
66
|
let itrCorrelationId = ''
|
|
51
67
|
let isForcedToRun = false
|
|
52
68
|
const config = {}
|
|
@@ -79,6 +95,20 @@ const itrSkippedSuitesCh = channel('ci:mocha:itr:skipped-suites')
|
|
|
79
95
|
|
|
80
96
|
const getCodeCoverageCh = channel('ci:nyc:get-coverage')
|
|
81
97
|
|
|
98
|
+
function warnDeprecatedMochaVersion (frameworkVersion) {
|
|
99
|
+
if (DD_MAJOR >= 6 || hasWarnedDeprecatedMochaVersion || !frameworkVersion ||
|
|
100
|
+
!satisfies(frameworkVersion, '<8.0.0')) {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
hasWarnedDeprecatedMochaVersion = true
|
|
105
|
+
// eslint-disable-next-line no-console
|
|
106
|
+
console.warn(
|
|
107
|
+
'dd-trace support for Mocha<8.0.0 is deprecated and will be removed in dd-trace v6. ' +
|
|
108
|
+
'Please upgrade Mocha to >=8.0.0.'
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
82
112
|
// Tests from workers do not come with `isFailed` method
|
|
83
113
|
function isTestFailed (test) {
|
|
84
114
|
if (test.isFailed) {
|
|
@@ -90,10 +120,56 @@ function isTestFailed (test) {
|
|
|
90
120
|
return false
|
|
91
121
|
}
|
|
92
122
|
|
|
123
|
+
function getRootSuiteStatus (rootTests) {
|
|
124
|
+
let status = 'pass'
|
|
125
|
+
if (rootTests.every(t => t.isPending())) {
|
|
126
|
+
status = 'skip'
|
|
127
|
+
} else {
|
|
128
|
+
for (const test of rootTests) {
|
|
129
|
+
if (test.state === 'failed' || test.timedOut || test._ddHookFailed) {
|
|
130
|
+
status = 'fail'
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return status
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function haveRootTestsFinished (rootTests) {
|
|
138
|
+
for (const test of rootTests) {
|
|
139
|
+
if (!test.isPending() && !test.state && !test.timedOut && !test._ddHookFailed) {
|
|
140
|
+
return false
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return true
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getSuitePath (suite) {
|
|
147
|
+
return getTestSuitePath(suite.file, process.cwd())
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function getSuitesToSkip (originalSuites) {
|
|
151
|
+
return getSuitesToSkipFromPaths(originalSuites.map(getSuitePath))
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getSuitesToSkipFromPaths (localSuites) {
|
|
155
|
+
const localSuitesSet = new Set(localSuites)
|
|
156
|
+
const suitesToSkipForRun = []
|
|
157
|
+
|
|
158
|
+
for (const suite of suitesToSkip) {
|
|
159
|
+
if (localSuitesSet.has(suite)) {
|
|
160
|
+
suitesToSkipForRun.push(suite)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return suitesToSkipForRun
|
|
165
|
+
}
|
|
166
|
+
|
|
93
167
|
function getFilteredSuites (originalSuites) {
|
|
168
|
+
const suitesToSkipForRun = getSuitesToSkip(originalSuites)
|
|
169
|
+
|
|
94
170
|
return originalSuites.reduce((acc, suite) => {
|
|
95
|
-
const testPath =
|
|
96
|
-
const shouldSkip =
|
|
171
|
+
const testPath = getSuitePath(suite)
|
|
172
|
+
const shouldSkip = suitesToSkipForRun.includes(testPath)
|
|
97
173
|
const isUnskippable = unskippableSuites.includes(suite.file)
|
|
98
174
|
if (shouldSkip && !isUnskippable) {
|
|
99
175
|
acc.skippedSuites.add(testPath)
|
|
@@ -101,7 +177,67 @@ function getFilteredSuites (originalSuites) {
|
|
|
101
177
|
acc.suitesToRun.push(suite)
|
|
102
178
|
}
|
|
103
179
|
return acc
|
|
104
|
-
}, { suitesToRun: [], skippedSuites: new Set() })
|
|
180
|
+
}, { suitesToRun: [], skippedSuites: new Set(), suitesToSkipForRun })
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function hasSkippableSuitesCoverage () {
|
|
184
|
+
return skippableSuitesCoverage &&
|
|
185
|
+
typeof skippableSuitesCoverage === 'object' &&
|
|
186
|
+
Object.keys(skippableSuitesCoverage).length > 0
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function isTiaCoverageBackfillEnabled () {
|
|
190
|
+
return config.isItrEnabled && config.isCoverageReportUploadEnabled
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function getCoverageRootDir () {
|
|
194
|
+
return config.repositoryRoot || process.cwd()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Recomputes whether a parallel worker result belongs to a modified suite.
|
|
199
|
+
*
|
|
200
|
+
* In parallel mode, `_ddIsModified` is set on Mocha Test objects inside the worker.
|
|
201
|
+
* The main process receives `Test.prototype.serialize()` output for test events,
|
|
202
|
+
* and that fixed serialization drops custom properties. We still need modified-test
|
|
203
|
+
* bookkeeping in the main process for EFD failure suppression, so infer it again
|
|
204
|
+
* from the suite path.
|
|
205
|
+
*
|
|
206
|
+
* @param {string} testSuiteAbsolutePath
|
|
207
|
+
* @returns {boolean}
|
|
208
|
+
*/
|
|
209
|
+
function isModifiedTestSuite (testSuiteAbsolutePath) {
|
|
210
|
+
const testPath = getTestSuitePath(testSuiteAbsolutePath, getCoverageRootDir())
|
|
211
|
+
return isModifiedTest(testPath, null, null, config.modifiedFiles, 'mocha')
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function shouldReportCodeCoverageLinesPct (hasBackfilledCoverage) {
|
|
215
|
+
return !isSuitesSkipped || hasBackfilledCoverage
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function getSkippedSuitesCoverageForRun () {
|
|
219
|
+
return isSuitesSkipped && isTiaCoverageBackfillEnabled() && hasSkippableSuitesCoverage()
|
|
220
|
+
? skippableSuitesCoverage
|
|
221
|
+
: {}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function applySkippedCoverageToMochaCoverageMap () {
|
|
225
|
+
if (!isTiaCoverageBackfillEnabled()) return false
|
|
226
|
+
return applySkippedCoverageToCoverage(originalCoverageMap, skippedSuitesCoverage, getCoverageRootDir())
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function getMochaTestSessionCoverageFiles () {
|
|
230
|
+
return getRelativeCoverageFiles(getExecutableFilesFromCoverage(originalCoverageMap), getCoverageRootDir())
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function resetSuiteSkippingRunState () {
|
|
234
|
+
isSuitesSkipped = false
|
|
235
|
+
skippedSuites = []
|
|
236
|
+
skippableSuitesCoverage = {}
|
|
237
|
+
skippedSuitesCoverage = {}
|
|
238
|
+
untestedCoverage = undefined
|
|
239
|
+
config.repositoryRoot = undefined
|
|
240
|
+
writeCoverageBackfillToCache({})
|
|
105
241
|
}
|
|
106
242
|
|
|
107
243
|
function getOnStartHandler (frameworkVersion) {
|
|
@@ -136,36 +272,28 @@ function getOnEndHandler (isParallel) {
|
|
|
136
272
|
* The rationale behind is the following: you may still be able to block your CI pipeline by gating
|
|
137
273
|
* on flakiness (the test will be considered flaky), but you may choose to unblock the pipeline too.
|
|
138
274
|
*/
|
|
139
|
-
for (const tests of Object.values(
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.failures -=
|
|
275
|
+
for (const tests of Object.values(efdTests)) {
|
|
276
|
+
const failingEfdTests = tests.filter(test => isTestFailed(test))
|
|
277
|
+
const areAllEfdTestsFailing = failingEfdTests.length === tests.length
|
|
278
|
+
const nonQuarantinedFailingEfdTests = failingEfdTests.filter(test => !testsQuarantined.has(test))
|
|
279
|
+
if (nonQuarantinedFailingEfdTests.length && !areAllEfdTestsFailing) {
|
|
280
|
+
this.stats.failures -= nonQuarantinedFailingEfdTests.length
|
|
281
|
+
this.failures -= nonQuarantinedFailingEfdTests.length
|
|
145
282
|
}
|
|
146
283
|
}
|
|
147
284
|
}
|
|
148
285
|
|
|
149
|
-
// We
|
|
150
|
-
//
|
|
286
|
+
// We subtract the errors from quarantined tests from the total number of failures.
|
|
287
|
+
// Attempt-to-fix tests ignore quarantine/disabled suppression and keep their framework result.
|
|
151
288
|
if (config.isTestManagementTestsEnabled) {
|
|
152
289
|
let numFailedQuarantinedTests = 0
|
|
153
|
-
let numFailedRetriedQuarantinedOrDisabledTests = 0
|
|
154
|
-
for (const test of testsAttemptToFix) {
|
|
155
|
-
const testName = getTestFullName(test)
|
|
156
|
-
const testProperties = getTestProperties(test, config.testManagementTests)
|
|
157
|
-
if (isTestFailed(test) && (testProperties.isQuarantined || testProperties.isDisabled)) {
|
|
158
|
-
const numFailedTests = testsStatuses.get(testName).filter(status => status === 'fail').length
|
|
159
|
-
numFailedRetriedQuarantinedOrDisabledTests += numFailedTests
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
290
|
for (const test of testsQuarantined) {
|
|
163
291
|
if (isTestFailed(test)) {
|
|
164
292
|
numFailedQuarantinedTests++
|
|
165
293
|
}
|
|
166
294
|
}
|
|
167
|
-
this.stats.failures -= numFailedQuarantinedTests
|
|
168
|
-
this.failures -= numFailedQuarantinedTests
|
|
295
|
+
this.stats.failures -= numFailedQuarantinedTests
|
|
296
|
+
this.failures -= numFailedQuarantinedTests
|
|
169
297
|
}
|
|
170
298
|
|
|
171
299
|
// Recompute status after EFD and quarantine adjustments have reduced failure counts
|
|
@@ -184,12 +312,24 @@ function getOnEndHandler (isParallel) {
|
|
|
184
312
|
testFileToSuiteCtx.clear()
|
|
185
313
|
|
|
186
314
|
let testCodeCoverageLinesTotal
|
|
187
|
-
|
|
315
|
+
let testSessionCoverageFiles
|
|
316
|
+
if (global.__coverage__ || untestedCoverage) {
|
|
188
317
|
try {
|
|
318
|
+
let hasBackfilledCoverage = false
|
|
189
319
|
if (untestedCoverage) {
|
|
190
320
|
originalCoverageMap.merge(fromCoverageMapToCoverage(untestedCoverage))
|
|
191
321
|
}
|
|
192
|
-
|
|
322
|
+
hasBackfilledCoverage = applySkippedCoverageToMochaCoverageMap()
|
|
323
|
+
if (shouldReportCodeCoverageLinesPct(hasBackfilledCoverage)) {
|
|
324
|
+
testCodeCoverageLinesTotal = getTestCoverageLinesPercentage(
|
|
325
|
+
originalCoverageMap,
|
|
326
|
+
undefined,
|
|
327
|
+
getCoverageRootDir()
|
|
328
|
+
)
|
|
329
|
+
}
|
|
330
|
+
if (isTiaCoverageBackfillEnabled()) {
|
|
331
|
+
testSessionCoverageFiles = getMochaTestSessionCoverageFiles()
|
|
332
|
+
}
|
|
193
333
|
} catch {
|
|
194
334
|
// ignore errors
|
|
195
335
|
}
|
|
@@ -201,6 +341,7 @@ function getOnEndHandler (isParallel) {
|
|
|
201
341
|
status,
|
|
202
342
|
isSuitesSkipped,
|
|
203
343
|
testCodeCoverageLinesTotal,
|
|
344
|
+
testSessionCoverageFiles,
|
|
204
345
|
numSkippedSuites: skippedSuites.length,
|
|
205
346
|
hasForcedToRunSuites: isForcedToRun,
|
|
206
347
|
hasUnskippableSuites: !!unskippableSuites.length,
|
|
@@ -211,26 +352,74 @@ function getOnEndHandler (isParallel) {
|
|
|
211
352
|
isParallel,
|
|
212
353
|
})
|
|
213
354
|
|
|
214
|
-
|
|
355
|
+
logTestOptimizationSummary({ attemptToFixExecutions, newTestsWithDynamicNames })
|
|
356
|
+
loggedAttemptToFixTests.clear()
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function getRunStoresPromise (channelToPublishTo, ctx) {
|
|
361
|
+
return new Promise(resolve => {
|
|
362
|
+
channelToPublishTo.runStores({ ...ctx, onDone: resolve }, () => {})
|
|
363
|
+
})
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function applyKnownTestsResponse ({ err, knownTests }) {
|
|
367
|
+
if (err) {
|
|
368
|
+
config.knownTests = []
|
|
369
|
+
config.isEarlyFlakeDetectionEnabled = false
|
|
370
|
+
config.isKnownTestsEnabled = false
|
|
371
|
+
} else {
|
|
372
|
+
config.knownTests = knownTests
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function applyTestManagementTestsResponse ({ err, testManagementTests: receivedTestManagementTests }) {
|
|
377
|
+
if (err) {
|
|
378
|
+
config.testManagementTests = {}
|
|
379
|
+
config.isTestManagementTestsEnabled = false
|
|
380
|
+
config.testManagementAttemptToFixRetries = 0
|
|
381
|
+
} else {
|
|
382
|
+
config.testManagementTests = receivedTestManagementTests
|
|
215
383
|
}
|
|
216
384
|
}
|
|
217
385
|
|
|
218
|
-
function
|
|
386
|
+
function isFailedTestReplayEnabled () {
|
|
387
|
+
return config.isTestDynamicInstrumentationEnabled && config.isDiEnabled
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFinishRequest, localSuites) {
|
|
219
391
|
const ctx = {
|
|
220
392
|
isParallel,
|
|
221
393
|
frameworkVersion,
|
|
222
394
|
}
|
|
223
|
-
|
|
224
|
-
|
|
395
|
+
let skippableSuitesResponse
|
|
396
|
+
resetSuiteSkippingRunState()
|
|
397
|
+
|
|
398
|
+
const onReceivedSkippableSuites = ({
|
|
399
|
+
err,
|
|
400
|
+
skippableSuites,
|
|
401
|
+
itrCorrelationId: responseItrCorrelationId,
|
|
402
|
+
skippableSuitesCoverage: responseSkippableSuitesCoverage,
|
|
403
|
+
}) => {
|
|
225
404
|
if (err) {
|
|
226
405
|
suitesToSkip = []
|
|
406
|
+
skippableSuitesCoverage = {}
|
|
227
407
|
} else {
|
|
228
408
|
suitesToSkip = skippableSuites
|
|
229
409
|
itrCorrelationId = responseItrCorrelationId
|
|
410
|
+
skippableSuitesCoverage = responseSkippableSuitesCoverage || {}
|
|
230
411
|
}
|
|
412
|
+
if (localSuites) {
|
|
413
|
+
suitesToSkip = getSuitesToSkipFromPaths(localSuites)
|
|
414
|
+
mochaGlobalRunCh.runStores(ctx, () => {
|
|
415
|
+
onFinishRequest()
|
|
416
|
+
})
|
|
417
|
+
return
|
|
418
|
+
}
|
|
419
|
+
|
|
231
420
|
// We remove the suites that we skip through ITR
|
|
232
421
|
const filteredSuites = getFilteredSuites(runner.suite.suites)
|
|
233
|
-
const { suitesToRun } = filteredSuites
|
|
422
|
+
const { suitesToRun, suitesToSkipForRun } = filteredSuites
|
|
234
423
|
|
|
235
424
|
isSuitesSkipped = suitesToRun.length !== runner.suite.suites.length
|
|
236
425
|
|
|
@@ -239,12 +428,25 @@ function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFini
|
|
|
239
428
|
runner.suite.suites = suitesToRun
|
|
240
429
|
|
|
241
430
|
skippedSuites = [...filteredSuites.skippedSuites]
|
|
431
|
+
suitesToSkip = suitesToSkipForRun
|
|
432
|
+
skippedSuitesCoverage = getSkippedSuitesCoverageForRun()
|
|
433
|
+
writeCoverageBackfillToCache(skippedSuitesCoverage, getCoverageRootDir())
|
|
242
434
|
|
|
243
435
|
mochaGlobalRunCh.runStores(ctx, () => {
|
|
244
436
|
onFinishRequest()
|
|
245
437
|
})
|
|
246
438
|
}
|
|
247
439
|
|
|
440
|
+
const requestSkippableSuites = () => {
|
|
441
|
+
if (skippableSuitesResponse) {
|
|
442
|
+
onReceivedSkippableSuites(skippableSuitesResponse)
|
|
443
|
+
return
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
ctx.onDone = onReceivedSkippableSuites
|
|
447
|
+
skippableSuitesCh.runStores(ctx, () => {})
|
|
448
|
+
}
|
|
449
|
+
|
|
248
450
|
const onReceivedImpactedTests = ({ err, modifiedFiles: receivedModifiedFiles }) => {
|
|
249
451
|
if (err) {
|
|
250
452
|
config.modifiedFiles = []
|
|
@@ -253,8 +455,7 @@ function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFini
|
|
|
253
455
|
config.modifiedFiles = receivedModifiedFiles
|
|
254
456
|
}
|
|
255
457
|
if (config.isSuitesSkippingEnabled) {
|
|
256
|
-
|
|
257
|
-
skippableSuitesCh.runStores(ctx, () => {})
|
|
458
|
+
requestSkippableSuites()
|
|
258
459
|
} else {
|
|
259
460
|
mochaGlobalRunCh.runStores(ctx, () => {
|
|
260
461
|
onFinishRequest()
|
|
@@ -262,20 +463,12 @@ function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFini
|
|
|
262
463
|
}
|
|
263
464
|
}
|
|
264
465
|
|
|
265
|
-
const
|
|
266
|
-
if (err) {
|
|
267
|
-
config.testManagementTests = {}
|
|
268
|
-
config.isTestManagementTestsEnabled = false
|
|
269
|
-
config.testManagementAttemptToFixRetries = 0
|
|
270
|
-
} else {
|
|
271
|
-
config.testManagementTests = receivedTestManagementTests
|
|
272
|
-
}
|
|
466
|
+
const continueAfterTestRequests = () => {
|
|
273
467
|
if (config.isImpactedTestsEnabled) {
|
|
274
468
|
ctx.onDone = onReceivedImpactedTests
|
|
275
469
|
modifiedFilesCh.runStores(ctx, () => {})
|
|
276
470
|
} else if (config.isSuitesSkippingEnabled) {
|
|
277
|
-
|
|
278
|
-
skippableSuitesCh.runStores(ctx, () => {})
|
|
471
|
+
requestSkippableSuites()
|
|
279
472
|
} else {
|
|
280
473
|
mochaGlobalRunCh.runStores(ctx, () => {
|
|
281
474
|
onFinishRequest()
|
|
@@ -283,64 +476,54 @@ function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFini
|
|
|
283
476
|
}
|
|
284
477
|
}
|
|
285
478
|
|
|
286
|
-
const
|
|
287
|
-
if (err) {
|
|
288
|
-
config.knownTests = []
|
|
289
|
-
config.isEarlyFlakeDetectionEnabled = false
|
|
290
|
-
config.isKnownTestsEnabled = false
|
|
291
|
-
} else {
|
|
292
|
-
config.knownTests = knownTests
|
|
293
|
-
}
|
|
294
|
-
if (config.isTestManagementTestsEnabled) {
|
|
295
|
-
ctx.onDone = onReceivedTestManagementTests
|
|
296
|
-
testManagementTestsCh.runStores(ctx, () => {})
|
|
297
|
-
} else if (config.isImpactedTestsEnabled) {
|
|
298
|
-
ctx.onDone = onReceivedImpactedTests
|
|
299
|
-
modifiedFilesCh.runStores(ctx, () => {})
|
|
300
|
-
} else if (config.isSuitesSkippingEnabled) {
|
|
301
|
-
ctx.onDone = onReceivedSkippableSuites
|
|
302
|
-
skippableSuitesCh.runStores(ctx, () => {})
|
|
303
|
-
} else {
|
|
304
|
-
mochaGlobalRunCh.runStores(ctx, () => {
|
|
305
|
-
onFinishRequest()
|
|
306
|
-
})
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
const onReceivedConfiguration = ({ err, libraryConfig }) => {
|
|
479
|
+
const onReceivedConfiguration = ({ err, isTestDynamicInstrumentationEnabled, libraryConfig, repositoryRoot }) => {
|
|
311
480
|
if (err || !skippableSuitesCh.hasSubscribers || !knownTestsCh.hasSubscribers) {
|
|
312
481
|
return mochaGlobalRunCh.runStores(ctx, () => {
|
|
313
482
|
onFinishRequest()
|
|
314
483
|
})
|
|
315
484
|
}
|
|
485
|
+
config.repositoryRoot = repositoryRoot
|
|
316
486
|
config.isEarlyFlakeDetectionEnabled = libraryConfig.isEarlyFlakeDetectionEnabled
|
|
317
487
|
config.earlyFlakeDetectionNumRetries = libraryConfig.earlyFlakeDetectionNumRetries
|
|
488
|
+
config.earlyFlakeDetectionSlowTestRetries = libraryConfig.earlyFlakeDetectionSlowTestRetries ?? {}
|
|
318
489
|
config.earlyFlakeDetectionFaultyThreshold = libraryConfig.earlyFlakeDetectionFaultyThreshold
|
|
319
490
|
config.isKnownTestsEnabled = libraryConfig.isKnownTestsEnabled
|
|
320
491
|
config.isTestManagementTestsEnabled = libraryConfig.isTestManagementEnabled
|
|
321
492
|
config.testManagementAttemptToFixRetries = libraryConfig.testManagementAttemptToFixRetries
|
|
322
493
|
config.isImpactedTestsEnabled = libraryConfig.isImpactedTestsEnabled
|
|
323
|
-
config.
|
|
494
|
+
config.isItrEnabled = libraryConfig.isItrEnabled
|
|
495
|
+
config.isCodeCoverageEnabled = libraryConfig.isCodeCoverageEnabled
|
|
496
|
+
config.isCoverageReportUploadEnabled = libraryConfig.isCoverageReportUploadEnabled
|
|
497
|
+
config.isSuitesSkippingEnabled = config.isItrEnabled && libraryConfig.isSuitesSkippingEnabled
|
|
324
498
|
config.isFlakyTestRetriesEnabled = libraryConfig.isFlakyTestRetriesEnabled
|
|
325
499
|
config.flakyTestRetriesCount = libraryConfig.flakyTestRetriesCount
|
|
500
|
+
config.isDiEnabled = libraryConfig.isDiEnabled
|
|
501
|
+
config.isTestDynamicInstrumentationEnabled = isTestDynamicInstrumentationEnabled
|
|
502
|
+
|
|
503
|
+
getTestOptimizationRequestResults({
|
|
504
|
+
isKnownTestsEnabled: config.isKnownTestsEnabled,
|
|
505
|
+
isTestManagementTestsEnabled: config.isTestManagementTestsEnabled,
|
|
506
|
+
isSuitesSkippingEnabled: config.isSuitesSkippingEnabled,
|
|
507
|
+
getKnownTests: () => getRunStoresPromise(knownTestsCh, ctx),
|
|
508
|
+
getTestManagementTests: () => getRunStoresPromise(testManagementTestsCh, ctx),
|
|
509
|
+
getSkippableSuites: () => getRunStoresPromise(skippableSuitesCh, ctx),
|
|
510
|
+
}).then(requestResults => {
|
|
511
|
+
const {
|
|
512
|
+
knownTestsResponse,
|
|
513
|
+
testManagementTestsResponse,
|
|
514
|
+
skippableSuitesResponse: requestSkippableSuitesResponse,
|
|
515
|
+
} = requestResults
|
|
516
|
+
|
|
517
|
+
if (knownTestsResponse) {
|
|
518
|
+
applyKnownTestsResponse(knownTestsResponse)
|
|
519
|
+
}
|
|
520
|
+
if (testManagementTestsResponse) {
|
|
521
|
+
applyTestManagementTestsResponse(testManagementTestsResponse)
|
|
522
|
+
}
|
|
523
|
+
skippableSuitesResponse = requestSkippableSuitesResponse
|
|
326
524
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
knownTestsCh.runStores(ctx, () => {})
|
|
330
|
-
} else if (config.isTestManagementTestsEnabled) {
|
|
331
|
-
ctx.onDone = onReceivedTestManagementTests
|
|
332
|
-
testManagementTestsCh.runStores(ctx, () => {})
|
|
333
|
-
} else if (config.isImpactedTestsEnabled) {
|
|
334
|
-
ctx.onDone = onReceivedImpactedTests
|
|
335
|
-
modifiedFilesCh.runStores(ctx, () => {})
|
|
336
|
-
} else if (config.isSuitesSkippingEnabled) {
|
|
337
|
-
ctx.onDone = onReceivedSkippableSuites
|
|
338
|
-
skippableSuitesCh.runStores(ctx, () => {})
|
|
339
|
-
} else {
|
|
340
|
-
mochaGlobalRunCh.runStores(ctx, () => {
|
|
341
|
-
onFinishRequest()
|
|
342
|
-
})
|
|
343
|
-
}
|
|
525
|
+
continueAfterTestRequests()
|
|
526
|
+
})
|
|
344
527
|
}
|
|
345
528
|
|
|
346
529
|
ctx.onDone = onReceivedConfiguration
|
|
@@ -353,20 +536,22 @@ function getExecutionConfiguration (runner, isParallel, frameworkVersion, onFini
|
|
|
353
536
|
// It is called but skipped in parallel mode.
|
|
354
537
|
addHook({
|
|
355
538
|
name: 'mocha',
|
|
356
|
-
versions: [
|
|
539
|
+
versions: [MINIMUM_MOCHA_VERSION],
|
|
357
540
|
file: 'lib/mocha.js',
|
|
358
541
|
}, (Mocha, frameworkVersion) => {
|
|
359
|
-
|
|
542
|
+
warnDeprecatedMochaVersion(frameworkVersion)
|
|
543
|
+
|
|
544
|
+
shimmer.wrap(Mocha.prototype, 'run', run => function (...args) {
|
|
360
545
|
// Workers do not need to request any data, just run the tests
|
|
361
546
|
if (!testFinishCh.hasSubscribers || getEnvironmentVariable('MOCHA_WORKER_ID') || this.options.parallel) {
|
|
362
|
-
return run.apply(this,
|
|
547
|
+
return run.apply(this, args)
|
|
363
548
|
}
|
|
364
549
|
|
|
365
550
|
// `options.delay` does not work in parallel mode, so we can't delay the execution this way
|
|
366
551
|
// This needs to be both here and in `runMocha` hook. Read the comment in `runMocha` hook for more info.
|
|
367
552
|
this.options.delay = true
|
|
368
553
|
|
|
369
|
-
const runner = run.apply(this,
|
|
554
|
+
const runner = run.apply(this, args)
|
|
370
555
|
|
|
371
556
|
// eslint-disable-next-line unicorn/no-array-for-each
|
|
372
557
|
this.files.forEach((path) => {
|
|
@@ -377,6 +562,9 @@ addHook({
|
|
|
377
562
|
})
|
|
378
563
|
|
|
379
564
|
getExecutionConfiguration(runner, false, frameworkVersion, () => {
|
|
565
|
+
if (isFailedTestReplayEnabled()) {
|
|
566
|
+
patchFailedTestReplayHookUp(runner.constructor)
|
|
567
|
+
}
|
|
380
568
|
if (config.isKnownTestsEnabled) {
|
|
381
569
|
const testSuites = this.files.map(file => getTestSuitePath(file, process.cwd()))
|
|
382
570
|
const isFaulty = getIsFaultyEarlyFlakeDetection(
|
|
@@ -409,15 +597,15 @@ addHook({
|
|
|
409
597
|
|
|
410
598
|
addHook({
|
|
411
599
|
name: 'mocha',
|
|
412
|
-
versions: [
|
|
600
|
+
versions: [MINIMUM_MOCHA_VERSION],
|
|
413
601
|
file: 'lib/cli/run-helpers.js',
|
|
414
602
|
}, (run) => {
|
|
415
603
|
// `runMocha` is an async function
|
|
416
|
-
shimmer.wrap(run, 'runMocha', runMocha => function () {
|
|
604
|
+
shimmer.wrap(run, 'runMocha', runMocha => function (...args) {
|
|
417
605
|
if (!testFinishCh.hasSubscribers) {
|
|
418
|
-
return runMocha.apply(this,
|
|
606
|
+
return runMocha.apply(this, args)
|
|
419
607
|
}
|
|
420
|
-
const mocha =
|
|
608
|
+
const mocha = args[0]
|
|
421
609
|
|
|
422
610
|
/**
|
|
423
611
|
* This attaches `run` to the global context, which we'll call after
|
|
@@ -431,7 +619,7 @@ addHook({
|
|
|
431
619
|
mocha.options.delay = true
|
|
432
620
|
}
|
|
433
621
|
|
|
434
|
-
return runMocha.apply(this,
|
|
622
|
+
return runMocha.apply(this, args)
|
|
435
623
|
})
|
|
436
624
|
return run
|
|
437
625
|
})
|
|
@@ -440,7 +628,7 @@ addHook({
|
|
|
440
628
|
// This hook is used to generate session, module, suite and test events
|
|
441
629
|
addHook({
|
|
442
630
|
name: 'mocha',
|
|
443
|
-
versions: [
|
|
631
|
+
versions: [MINIMUM_MOCHA_VERSION],
|
|
444
632
|
file: 'lib/runner.js',
|
|
445
633
|
}, function (Runner, frameworkVersion) {
|
|
446
634
|
if (patched.has(Runner)) return Runner
|
|
@@ -449,32 +637,216 @@ addHook({
|
|
|
449
637
|
|
|
450
638
|
shimmer.wrap(Runner.prototype, 'runTests', runTests => getRunTestsWrapper(runTests, config))
|
|
451
639
|
|
|
452
|
-
shimmer.wrap(Runner.prototype, 'run', run => function () {
|
|
640
|
+
shimmer.wrap(Runner.prototype, 'run', run => function (...args) {
|
|
453
641
|
if (!testFinishCh.hasSubscribers) {
|
|
454
|
-
return run.apply(this,
|
|
642
|
+
return run.apply(this, args)
|
|
455
643
|
}
|
|
456
644
|
|
|
457
645
|
const { suitesByTestFile, numSuitesByTestFile } = getSuitesByTestFile(this.suite)
|
|
646
|
+
// Root-level tests (direct children of root, no describe wrapper) keyed by file.
|
|
647
|
+
// Populated during the root 'suite' event so the normal finish path can include them
|
|
648
|
+
// in mixed-file status calculation.
|
|
649
|
+
const rootTestsByFile = new Map()
|
|
650
|
+
// Counts how many original tests per pure-root file still need their final attempt.
|
|
651
|
+
// Hits zero when the last test's lifecycle completes, triggering the suite finish.
|
|
652
|
+
const rootPendingCountByFile = new Map()
|
|
653
|
+
const rootFinalizationPendingCountByFile = new Map()
|
|
654
|
+
const rootFallbackPendingFiles = new Set()
|
|
655
|
+
const rootFinalizationPendingTests = new WeakSet()
|
|
656
|
+
let pendingRootFinalizations = 0
|
|
657
|
+
let hasEnded = false
|
|
658
|
+
let hasFinishedRun = false
|
|
659
|
+
let endRunner
|
|
660
|
+
|
|
661
|
+
function updateRootTestForFinalAttempt (test) {
|
|
662
|
+
if (!test._retriedTest) return
|
|
663
|
+
|
|
664
|
+
const rootTests = rootTestsByFile.get(test.file)
|
|
665
|
+
if (!rootTests) return
|
|
666
|
+
|
|
667
|
+
const retriedTestIndex = rootTests.indexOf(test._retriedTest)
|
|
668
|
+
if (retriedTestIndex !== -1) {
|
|
669
|
+
rootTests[retriedTestIndex] = test
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
function finishRunIfReady () {
|
|
674
|
+
if (hasFinishedRun) return
|
|
675
|
+
if (hasEnded && pendingRootFinalizations === 0) {
|
|
676
|
+
hasFinishedRun = true
|
|
677
|
+
onEnd.call(endRunner)
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
function incrementPendingRootFinalization (test) {
|
|
682
|
+
if (!rootPendingCountByFile.has(test.file) || rootFinalizationPendingTests.has(test)) return
|
|
683
|
+
|
|
684
|
+
rootFinalizationPendingTests.add(test)
|
|
685
|
+
pendingRootFinalizations++
|
|
686
|
+
rootFinalizationPendingCountByFile.set(
|
|
687
|
+
test.file,
|
|
688
|
+
(rootFinalizationPendingCountByFile.get(test.file) || 0) + 1
|
|
689
|
+
)
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function decrementPendingRootFinalization (test) {
|
|
693
|
+
if (!rootFinalizationPendingTests.has(test)) return
|
|
694
|
+
|
|
695
|
+
rootFinalizationPendingTests.delete(test)
|
|
696
|
+
pendingRootFinalizations--
|
|
697
|
+
|
|
698
|
+
const remaining = rootFinalizationPendingCountByFile.get(test.file) - 1
|
|
699
|
+
if (remaining > 0) {
|
|
700
|
+
rootFinalizationPendingCountByFile.set(test.file, remaining)
|
|
701
|
+
} else {
|
|
702
|
+
rootFinalizationPendingCountByFile.delete(test.file)
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
if (!rootFinalizationPendingCountByFile.has(test.file) && rootFallbackPendingFiles.delete(test.file)) {
|
|
706
|
+
finishRootSuiteFallbackForFile(test.file)
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
finishRunIfReady()
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
function finishRootSuiteForFile (file) {
|
|
713
|
+
const remaining = rootPendingCountByFile.get(file) - 1
|
|
714
|
+
if (remaining > 0) {
|
|
715
|
+
rootPendingCountByFile.set(file, remaining)
|
|
716
|
+
return
|
|
717
|
+
}
|
|
718
|
+
rootPendingCountByFile.delete(file)
|
|
719
|
+
|
|
720
|
+
const ctx = testFileToSuiteCtx.get(file)
|
|
721
|
+
if (!ctx) {
|
|
722
|
+
log.warn('No ctx found for suite', file)
|
|
723
|
+
return
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
const rootTests = rootTestsByFile.get(file) || []
|
|
727
|
+
const status = getRootSuiteStatus(rootTests)
|
|
728
|
+
|
|
729
|
+
if (global.__coverage__) {
|
|
730
|
+
const coverageFiles = getCoveredFilesFromCoverage(global.__coverage__)
|
|
731
|
+
testSuiteCodeCoverageCh.publish({ coverageFiles, suiteFile: file })
|
|
732
|
+
mergeCoverage(global.__coverage__, originalCoverageMap)
|
|
733
|
+
resetCoverage(global.__coverage__)
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
testSuiteFinishCh.publish({ status, ...ctx.currentStore }, () => {})
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
function finishRootSuiteFallbackForFile (file) {
|
|
740
|
+
const ctx = testFileToSuiteCtx.get(file)
|
|
741
|
+
if (!ctx || !rootPendingCountByFile.has(file)) return
|
|
742
|
+
|
|
743
|
+
const rootTests = rootTestsByFile.get(file) || []
|
|
744
|
+
const status = haveRootTestsFinished(rootTests) ? getRootSuiteStatus(rootTests) : 'fail'
|
|
745
|
+
rootPendingCountByFile.delete(file)
|
|
746
|
+
testSuiteFinishCh.publish({ status, ...ctx.currentStore }, () => {})
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
function finishRootSuiteAfterFinalAttempt (test) {
|
|
750
|
+
if (!test._ddIsFinalAttempt || !rootPendingCountByFile.has(test.file)) return
|
|
751
|
+
|
|
752
|
+
updateRootTestForFinalAttempt(test)
|
|
753
|
+
finishRootSuiteForFile(test.file)
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
const onEnd = getOnEndHandler(false)
|
|
458
757
|
|
|
459
758
|
this.once('start', getOnStartHandler(frameworkVersion))
|
|
460
759
|
|
|
461
|
-
this.once('end',
|
|
760
|
+
this.once('end', function () {
|
|
761
|
+
hasEnded = true
|
|
762
|
+
endRunner = this
|
|
763
|
+
finishRunIfReady()
|
|
764
|
+
})
|
|
765
|
+
|
|
766
|
+
// The job of this listener is to
|
|
767
|
+
// initialize the suite span tag in correct order
|
|
768
|
+
// (that is suiteA -> testA ... -> suiteB -> testB
|
|
769
|
+
// instead of suiteA -> suiteB -> testA -> ... -> testB)
|
|
770
|
+
// when the suite has tests that are in the top level
|
|
771
|
+
// (no describe(...))
|
|
772
|
+
this.on('test', function (test) {
|
|
773
|
+
const ctx = testFileToSuiteCtx.get(test.file)
|
|
774
|
+
if (ctx?._pendingRootStart) {
|
|
775
|
+
ctx._pendingRootStart = false
|
|
776
|
+
testSuiteStartCh.runStores(ctx, () => {})
|
|
777
|
+
}
|
|
778
|
+
})
|
|
462
779
|
|
|
463
780
|
this.on('test', getOnTestHandler(true))
|
|
464
781
|
|
|
465
|
-
this.on('test end', getOnTestEndHandler(config
|
|
782
|
+
this.on('test end', getOnTestEndHandler(config, {
|
|
783
|
+
onStart: incrementPendingRootFinalization,
|
|
784
|
+
onFinish: function (test) {
|
|
785
|
+
finishRootSuiteAfterFinalAttempt(test)
|
|
786
|
+
decrementPendingRootFinalization(test)
|
|
787
|
+
},
|
|
788
|
+
}))
|
|
466
789
|
|
|
467
790
|
this.on('retry', getOnTestRetryHandler(config))
|
|
468
791
|
|
|
469
792
|
// If the hook passes, 'hook end' will be emitted. Otherwise, 'fail' will be emitted
|
|
470
|
-
this.on('hook end', getOnHookEndHandler(
|
|
793
|
+
this.on('hook end', getOnHookEndHandler(config, {
|
|
794
|
+
onStart: incrementPendingRootFinalization,
|
|
795
|
+
onFinish: function (test) {
|
|
796
|
+
finishRootSuiteAfterFinalAttempt(test)
|
|
797
|
+
decrementPendingRootFinalization(test)
|
|
798
|
+
},
|
|
799
|
+
}))
|
|
800
|
+
|
|
801
|
+
this.on('hook end', function (hook) {
|
|
802
|
+
const test = hook.ctx?.currentTest
|
|
803
|
+
if (!test) return
|
|
804
|
+
finishRootSuiteAfterFinalAttempt(test)
|
|
805
|
+
})
|
|
806
|
+
|
|
807
|
+
this.on('fail', getOnFailHandler(true, config))
|
|
471
808
|
|
|
472
|
-
this.on('fail',
|
|
809
|
+
this.on('fail', function (testOrHook) {
|
|
810
|
+
if (testOrHook.type !== 'hook') return
|
|
811
|
+
const test = testOrHook.ctx?.currentTest
|
|
812
|
+
if (!test) return
|
|
813
|
+
finishRootSuiteAfterFinalAttempt(test)
|
|
814
|
+
})
|
|
473
815
|
|
|
474
816
|
this.on('pending', getOnPendingHandler())
|
|
475
817
|
|
|
476
818
|
this.on('suite', function (suite) {
|
|
477
819
|
if (suite.root || !suite.tests.length) {
|
|
820
|
+
// This branch can be triggered when we have top level it(...) inside test files.
|
|
821
|
+
// In that case, they all (even if they are from different files) are going to be
|
|
822
|
+
// children of the root suite.
|
|
823
|
+
// Note: We could have suites that contain top level it(...) and also it(...) nested
|
|
824
|
+
// inside describe(...) ("mixed case"). Duplication is avoided by the context guard
|
|
825
|
+
// below. Since 'suite' fires for root first, in the mixed case the ctx is created
|
|
826
|
+
// here and the describe-based handler finds it already set.
|
|
827
|
+
if (suite.root && suite.tests.length > 0) {
|
|
828
|
+
const files = new Set(suite.tests.map(test => test.file).filter(Boolean))
|
|
829
|
+
for (const file of files) {
|
|
830
|
+
const testsForFile = suite.tests.filter(t => t.file === file)
|
|
831
|
+
rootTestsByFile.set(file, testsForFile)
|
|
832
|
+
// Only track the countdown for pure root-level files.
|
|
833
|
+
// Mixed files are finished by the normal 'suite end' path.
|
|
834
|
+
if (!suitesByTestFile[file]) {
|
|
835
|
+
rootPendingCountByFile.set(file, testsForFile.length)
|
|
836
|
+
}
|
|
837
|
+
if (testFileToSuiteCtx.get(file)) continue
|
|
838
|
+
const isUnskippable = unskippableSuites.includes(file)
|
|
839
|
+
isForcedToRun = isUnskippable && suitesToSkip.includes(getTestSuitePath(file, process.cwd()))
|
|
840
|
+
const ctx = {
|
|
841
|
+
testSuiteAbsolutePath: file,
|
|
842
|
+
isUnskippable,
|
|
843
|
+
isForcedToRun,
|
|
844
|
+
itrCorrelationId,
|
|
845
|
+
_pendingRootStart: true, // Now the suite start fires lazily on the first test event for this file
|
|
846
|
+
}
|
|
847
|
+
testFileToSuiteCtx.set(file, ctx)
|
|
848
|
+
}
|
|
849
|
+
}
|
|
478
850
|
return
|
|
479
851
|
}
|
|
480
852
|
let ctx = testFileToSuiteCtx.get(suite.file)
|
|
@@ -494,6 +866,40 @@ addHook({
|
|
|
494
866
|
|
|
495
867
|
this.on('suite end', function (suite) {
|
|
496
868
|
if (suite.root) {
|
|
869
|
+
// Normal case: pure root-level files are finished by the 'test end' / 'hook end'
|
|
870
|
+
// listeners via finishRootSuiteForFile. Two edge cases remain here:
|
|
871
|
+
//
|
|
872
|
+
// 1. All-pending: no 'test' event fired, _pendingRootStart is still true.
|
|
873
|
+
// Start and immediately finish with 'skip'.
|
|
874
|
+
//
|
|
875
|
+
// 2. Aborted mid-run (e.g. a beforeEach hook failure): Mocha skips remaining
|
|
876
|
+
// tests and jumps straight to 'suite end'. rootPendingCountByFile still has
|
|
877
|
+
// a nonzero count for the file because the last tests never ran. Finish it
|
|
878
|
+
// as failed now.
|
|
879
|
+
//
|
|
880
|
+
// 3. Async finalization lagged behind Mocha's synchronous events (e.g. DI retry
|
|
881
|
+
// wait): all tests have Mocha terminal state, but the final-attempt callback
|
|
882
|
+
// did not run before root 'suite end'. Finish from the observed test states.
|
|
883
|
+
const processedFiles = new Set()
|
|
884
|
+
for (const test of suite.tests) {
|
|
885
|
+
if (!test.file || processedFiles.has(test.file)) continue
|
|
886
|
+
processedFiles.add(test.file)
|
|
887
|
+
if (suitesByTestFile[test.file]) continue // mixed: handled by normal path
|
|
888
|
+
const ctx = testFileToSuiteCtx.get(test.file)
|
|
889
|
+
if (!ctx) continue
|
|
890
|
+
if (ctx._pendingRootStart) {
|
|
891
|
+
ctx._pendingRootStart = false
|
|
892
|
+
testSuiteStartCh.runStores(ctx, () => {})
|
|
893
|
+
testSuiteFinishCh.publish({ status: 'skip', ...ctx.currentStore }, () => {})
|
|
894
|
+
} else if (rootPendingCountByFile.has(test.file)) {
|
|
895
|
+
if (rootFinalizationPendingCountByFile.has(test.file)) {
|
|
896
|
+
rootFallbackPendingFiles.add(test.file)
|
|
897
|
+
continue
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
finishRootSuiteFallbackForFile(test.file)
|
|
901
|
+
}
|
|
902
|
+
}
|
|
497
903
|
return
|
|
498
904
|
}
|
|
499
905
|
const suitesInTestFile = suitesByTestFile[suite.file]
|
|
@@ -503,8 +909,9 @@ addHook({
|
|
|
503
909
|
return
|
|
504
910
|
}
|
|
505
911
|
|
|
912
|
+
const rootTests = rootTestsByFile.get(suite.file) || []
|
|
506
913
|
let status = 'pass'
|
|
507
|
-
if (suitesInTestFile.every(suite => suite.pending)) {
|
|
914
|
+
if (suitesInTestFile.every(suite => suite.pending) && rootTests.every(test => test.isPending())) {
|
|
508
915
|
status = 'skip'
|
|
509
916
|
} else {
|
|
510
917
|
// has to check every test in the test file
|
|
@@ -516,10 +923,15 @@ addHook({
|
|
|
516
923
|
}
|
|
517
924
|
})
|
|
518
925
|
})
|
|
926
|
+
for (const test of rootTests) {
|
|
927
|
+
if (test.state === 'failed' || test.timedOut) {
|
|
928
|
+
status = 'fail'
|
|
929
|
+
}
|
|
930
|
+
}
|
|
519
931
|
}
|
|
520
932
|
|
|
521
933
|
if (global.__coverage__) {
|
|
522
|
-
const coverageFiles =
|
|
934
|
+
const coverageFiles = getCoveredFilesFromCoverage(global.__coverage__)
|
|
523
935
|
|
|
524
936
|
testSuiteCodeCoverageCh.publish({
|
|
525
937
|
coverageFiles,
|
|
@@ -539,7 +951,7 @@ addHook({
|
|
|
539
951
|
}
|
|
540
952
|
})
|
|
541
953
|
|
|
542
|
-
return run.apply(this,
|
|
954
|
+
return run.apply(this, args)
|
|
543
955
|
})
|
|
544
956
|
|
|
545
957
|
return Runner
|
|
@@ -549,7 +961,7 @@ addHook({
|
|
|
549
961
|
// Used to set the correct async resource to the test.
|
|
550
962
|
addHook({
|
|
551
963
|
name: 'mocha',
|
|
552
|
-
versions: [
|
|
964
|
+
versions: [MINIMUM_MOCHA_VERSION],
|
|
553
965
|
file: 'lib/runnable.js',
|
|
554
966
|
}, (runnablePackage) => runnableWrapper(runnablePackage, config))
|
|
555
967
|
|
|
@@ -557,7 +969,10 @@ function onMessage (message) {
|
|
|
557
969
|
if (Array.isArray(message)) {
|
|
558
970
|
const [messageCode, payload] = message
|
|
559
971
|
if (messageCode === MOCHA_WORKER_TRACE_PAYLOAD_CODE) {
|
|
560
|
-
|
|
972
|
+
collectTestOptimizationSummariesFromTraces(payload, {
|
|
973
|
+
newTestsWithDynamicNames,
|
|
974
|
+
attemptToFixExecutions,
|
|
975
|
+
})
|
|
561
976
|
workerReportTraceCh.publish(payload)
|
|
562
977
|
}
|
|
563
978
|
}
|
|
@@ -638,11 +1053,11 @@ addHook({
|
|
|
638
1053
|
}
|
|
639
1054
|
}
|
|
640
1055
|
|
|
1056
|
+
const localSuites = files.map(file => getTestSuitePath(file, process.cwd()))
|
|
641
1057
|
getExecutionConfiguration(this, true, frameworkVersion, () => {
|
|
642
1058
|
if (config.isKnownTestsEnabled) {
|
|
643
|
-
const testSuites = files.map(file => getTestSuitePath(file, process.cwd()))
|
|
644
1059
|
const isFaulty = getIsFaultyEarlyFlakeDetection(
|
|
645
|
-
|
|
1060
|
+
localSuites,
|
|
646
1061
|
config.knownTests?.mocha || {},
|
|
647
1062
|
config.earlyFlakeDetectionFaultyThreshold
|
|
648
1063
|
)
|
|
@@ -667,11 +1082,13 @@ addHook({
|
|
|
667
1082
|
}
|
|
668
1083
|
isSuitesSkipped = skippedFiles.length > 0
|
|
669
1084
|
skippedSuites = skippedFiles
|
|
1085
|
+
skippedSuitesCoverage = getSkippedSuitesCoverageForRun()
|
|
1086
|
+
writeCoverageBackfillToCache(skippedSuitesCoverage, getCoverageRootDir())
|
|
670
1087
|
run.apply(this, [cb, { files: filteredFiles }])
|
|
671
1088
|
} else {
|
|
672
1089
|
run.apply(this, arguments)
|
|
673
1090
|
}
|
|
674
|
-
})
|
|
1091
|
+
}, localSuites)
|
|
675
1092
|
|
|
676
1093
|
return this
|
|
677
1094
|
})
|
|
@@ -692,9 +1109,10 @@ addHook({
|
|
|
692
1109
|
shimmer.wrap(BufferedWorkerPool.prototype, 'run', run => async function (testSuiteAbsolutePath, workerArgs) {
|
|
693
1110
|
if (!testFinishCh.hasSubscribers ||
|
|
694
1111
|
(!config.isKnownTestsEnabled &&
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
1112
|
+
!config.isTestManagementTestsEnabled &&
|
|
1113
|
+
!config.isImpactedTestsEnabled &&
|
|
1114
|
+
!config.isFlakyTestRetriesEnabled &&
|
|
1115
|
+
!isFailedTestReplayEnabled())) {
|
|
698
1116
|
return run.apply(this, arguments)
|
|
699
1117
|
}
|
|
700
1118
|
|
|
@@ -706,6 +1124,7 @@ addHook({
|
|
|
706
1124
|
if (config.knownTests?.mocha) {
|
|
707
1125
|
const testSuiteKnownTests = config.knownTests.mocha[testPath] || []
|
|
708
1126
|
newWorkerArgs._ddEfdNumRetries = config.earlyFlakeDetectionNumRetries
|
|
1127
|
+
newWorkerArgs._ddEfdSlowTestRetries = config.earlyFlakeDetectionSlowTestRetries
|
|
709
1128
|
newWorkerArgs._ddIsEfdEnabled = config.isEarlyFlakeDetectionEnabled
|
|
710
1129
|
newWorkerArgs._ddIsKnownTestsEnabled = true
|
|
711
1130
|
newWorkerArgs._ddKnownTests = {
|
|
@@ -744,6 +1163,10 @@ addHook({
|
|
|
744
1163
|
newWorkerArgs._ddFlakyTestRetriesCount = config.flakyTestRetriesCount
|
|
745
1164
|
}
|
|
746
1165
|
|
|
1166
|
+
if (isFailedTestReplayEnabled()) {
|
|
1167
|
+
newWorkerArgs._ddIsFailedTestReplayEnabled = true
|
|
1168
|
+
}
|
|
1169
|
+
|
|
747
1170
|
// We pass the known tests for the test file to the worker
|
|
748
1171
|
const testFileResult = await run.apply(
|
|
749
1172
|
this,
|
|
@@ -757,10 +1180,15 @@ addHook({
|
|
|
757
1180
|
.events
|
|
758
1181
|
.filter(event => event.eventName === 'test end')
|
|
759
1182
|
.map(event => event.data)
|
|
1183
|
+
const isModified = config.isImpactedTestsEnabled && isModifiedTestSuite(testSuiteAbsolutePath)
|
|
760
1184
|
|
|
761
1185
|
for (const test of tests) {
|
|
1186
|
+
const testProperties = getTestProperties(test, config.testManagementTests)
|
|
1187
|
+
const isAttemptToFix = config.isTestManagementTestsEnabled && testProperties.isAttemptToFix
|
|
1188
|
+
|
|
762
1189
|
// `newTests` is filled in the worker process, so we need to use the test results to fill it here too.
|
|
763
|
-
|
|
1190
|
+
const isNew = config.isKnownTestsEnabled && isNewTest(test, config.knownTests)
|
|
1191
|
+
if (isNew) {
|
|
764
1192
|
const testFullName = getTestFullName(test)
|
|
765
1193
|
const tests = newTests[testFullName]
|
|
766
1194
|
|
|
@@ -770,8 +1198,19 @@ addHook({
|
|
|
770
1198
|
newTests[testFullName] = [test]
|
|
771
1199
|
}
|
|
772
1200
|
}
|
|
1201
|
+
// `efdTests` is filled in the worker process, so we need to use the test results to fill it here too.
|
|
1202
|
+
if (!isAttemptToFix && (isNew || isModified)) {
|
|
1203
|
+
const testFullName = getTestFullName(test)
|
|
1204
|
+
const tests = efdTests[testFullName]
|
|
1205
|
+
|
|
1206
|
+
if (tests) {
|
|
1207
|
+
tests.push(test)
|
|
1208
|
+
} else {
|
|
1209
|
+
efdTests[testFullName] = [test]
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
773
1212
|
// `testsQuarantined` is filled in the worker process, so we need to use the test results to fill it here too.
|
|
774
|
-
if (config.isTestManagementTestsEnabled &&
|
|
1213
|
+
if (config.isTestManagementTestsEnabled && testProperties.isQuarantined && !testProperties.isAttemptToFix) {
|
|
775
1214
|
testsQuarantined.add(test)
|
|
776
1215
|
}
|
|
777
1216
|
}
|