@depup/dd-trace 5.97.0-depup.0 → 6.5.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.electron.md +7 -0
- package/README.md +2 -2
- package/changes.json +1 -1
- package/ci/diagnose.js +2100 -0
- package/ci/init.js +46 -5
- package/ci/runbook.md +198 -0
- package/ci/test-optimization-validation/approval-artifacts.js +143 -0
- package/ci/test-optimization-validation/approval.js +299 -0
- package/ci/test-optimization-validation/artifact-id.js +20 -0
- package/ci/test-optimization-validation/bounded-json.js +121 -0
- package/ci/test-optimization-validation/ci-command-candidate.js +83 -0
- package/ci/test-optimization-validation/ci-discovery.js +181 -0
- package/ci/test-optimization-validation/ci-remediation.js +210 -0
- package/ci/test-optimization-validation/cli.js +903 -0
- package/ci/test-optimization-validation/command-blocker.js +81 -0
- package/ci/test-optimization-validation/command-output-policy.js +206 -0
- package/ci/test-optimization-validation/command-runner.js +707 -0
- package/ci/test-optimization-validation/command-suitability.js +471 -0
- package/ci/test-optimization-validation/executable-approval.js +48 -0
- package/ci/test-optimization-validation/executable.js +480 -0
- package/ci/test-optimization-validation/generated-file-policy.js +63 -0
- package/ci/test-optimization-validation/generated-files.js +351 -0
- package/ci/test-optimization-validation/generated-verifier.js +196 -0
- package/ci/test-optimization-validation/init-probe-preload.js +163 -0
- package/ci/test-optimization-validation/init-probe.js +246 -0
- package/ci/test-optimization-validation/late-initialization.js +63 -0
- package/ci/test-optimization-validation/local-command.js +163 -0
- package/ci/test-optimization-validation/manifest-loader.js +133 -0
- package/ci/test-optimization-validation/manifest-scaffold.js +738 -0
- package/ci/test-optimization-validation/manifest-schema.js +862 -0
- package/ci/test-optimization-validation/offline-fixtures.js +327 -0
- package/ci/test-optimization-validation/offline-output.js +406 -0
- package/ci/test-optimization-validation/payload-normalizer.js +72 -0
- package/ci/test-optimization-validation/plan-writer.js +1120 -0
- package/ci/test-optimization-validation/preflight-runner.js +114 -0
- package/ci/test-optimization-validation/redaction.js +331 -0
- package/ci/test-optimization-validation/report-writer.js +1508 -0
- package/ci/test-optimization-validation/safe-files.js +203 -0
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +159 -0
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +657 -0
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +780 -0
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +141 -0
- package/ci/test-optimization-validation/scenarios/helpers.js +539 -0
- package/ci/test-optimization-validation/scenarios/test-management.js +218 -0
- package/ci/test-optimization-validation/setup-runner.js +97 -0
- package/ci/test-optimization-validation/static-diagnosis.js +159 -0
- package/ci/test-optimization-validation/test-output.js +129 -0
- package/ci/test-optimization-validation-manifest.schema.json +1 -0
- package/ci/validate-test-optimization.js +3 -0
- package/ci/vitest-no-worker-init-setup.mjs +430 -0
- package/ext/exporters.js +2 -0
- package/ext/tags.js +3 -0
- package/index.d.ts +436 -252
- package/index.electron.js +3 -0
- package/init.js +18 -0
- package/initialize.mjs +10 -9
- package/loader-hook.mjs +170 -53
- package/openfeature.d.ts +1 -0
- package/openfeature.js +4 -0
- package/package.json +118 -80
- 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 +137 -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 +16 -16
- 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 +25 -0
- package/packages/datadog-instrumentations/src/cucumber.js +762 -189
- package/packages/datadog-instrumentations/src/cypress-config.js +547 -93
- 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 +166 -87
- 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 +31 -7
- 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/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 +111 -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 +1809 -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 -120
- package/packages/datadog-instrumentations/src/mocha/utils.js +531 -135
- 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 +82 -8
- package/packages/datadog-instrumentations/src/mongoose.js +46 -37
- package/packages/datadog-instrumentations/src/mquery.js +7 -7
- 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 +68 -10
- package/packages/datadog-instrumentations/src/nyc.js +43 -8
- 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 +1229 -356
- package/packages/datadog-instrumentations/src/process.js +3 -0
- 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 +253 -87
- package/packages/datadog-instrumentations/src/selenium.js +53 -28
- 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 +1590 -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 +9 -8
- 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 +80 -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-aws-sdk/src/util.js +2 -2
- 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 +47 -29
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +929 -98
- package/packages/datadog-plugin-cypress/src/index.js +109 -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 +272 -51
- 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 +748 -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 +54 -8
- 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 +7 -4
- 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-langchain/src/handlers/embedding.js +2 -1
- package/packages/datadog-plugin-langchain/src/handlers/language_models.js +2 -1
- package/packages/datadog-plugin-langchain/src/tokens.js +2 -2
- 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 +195 -72
- 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 +55 -44
- package/packages/datadog-plugin-selenium/src/index.js +5 -36
- 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 +5 -2
- package/packages/datadog-plugin-ws/src/producer.js +4 -1
- package/packages/datadog-plugin-ws/src/receiver.js +4 -2
- package/packages/datadog-plugin-ws/src/server.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 +148 -55
- 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/plugin.js +2 -2
- 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/telemetry/span-tags.js +3 -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 +19 -7
- 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 +123 -33
- 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-validation/index.js +160 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +288 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +84 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +369 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +60 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +188 -27
- 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 +110 -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 +10 -6
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +156 -0
- package/packages/dd-trace/src/ci-visibility/rum.js +7 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +9 -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 +256 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +451 -0
- package/packages/dd-trace/src/ci-visibility/test-screenshot.js +90 -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 +692 -131
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/config/helper.js +140 -33
- package/packages/dd-trace/src/config/index.js +127 -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 +460 -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 +5 -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/client-library-headers.js +21 -0
- package/packages/dd-trace/src/exporters/common/request.js +93 -44
- package/packages/dd-trace/src/exporters/common/retry.js +104 -0
- package/packages/dd-trace/src/exporters/common/url.js +48 -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 +29 -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/experiments/client.js +113 -0
- package/packages/dd-trace/src/llmobs/experiments/dataset.js +154 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +283 -0
- package/packages/dd-trace/src/llmobs/experiments/index.js +152 -0
- package/packages/dd-trace/src/llmobs/experiments/noop.js +30 -0
- package/packages/dd-trace/src/llmobs/experiments/result.js +34 -0
- package/packages/dd-trace/src/llmobs/index.js +37 -7
- package/packages/dd-trace/src/llmobs/noop.js +6 -0
- 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 +380 -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 +4 -29
- 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/constants.js +8 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +68 -64
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +43 -0
- package/packages/dd-trace/src/llmobs/sdk.js +73 -35
- package/packages/dd-trace/src/llmobs/span_processor.js +90 -11
- package/packages/dd-trace/src/llmobs/tagger.js +197 -4
- package/packages/dd-trace/src/llmobs/telemetry.js +33 -2
- package/packages/dd-trace/src/llmobs/util.js +234 -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/agentless_configuration_source.js +322 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +90 -0
- 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 +32 -16
- package/packages/dd-trace/src/openfeature/index.js +0 -2
- package/packages/dd-trace/src/openfeature/noop.js +41 -64
- package/packages/dd-trace/src/openfeature/register.js +35 -0
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -14
- package/packages/dd-trace/src/openfeature/require-provider.js +18 -0
- 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-ending-hook.js +10 -0
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +325 -0
- package/packages/dd-trace/src/opentelemetry/span.js +64 -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 +407 -91
- 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 +6 -3
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +276 -0
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +29 -5
- 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 +950 -69
- 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 +128 -37
- 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 +18 -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 +0 -36
- 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 +22 -22
- 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 +57 -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,1268 +1,17 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
const { getEnvironmentVariable } = require('../../dd-trace/src/config/helper')
|
|
4
|
+
const { isTrue } = require('../../dd-trace/src/util')
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const VITEST_NO_WORKER_INIT_ACTIVE_ENV = 'DD_TEST_OPT_VITEST_NO_WORKER_INIT_ACTIVE'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
DYNAMIC_NAME_RE,
|
|
14
|
-
collectDynamicNamesFromTraces,
|
|
15
|
-
logDynamicNamesWarning,
|
|
16
|
-
} = require('../../dd-trace/src/plugins/util/test')
|
|
17
|
-
const { addHook, channel } = require('./helpers/instrument')
|
|
8
|
+
if (getEnvironmentVariable('DD_VITEST_WORKER') === '1') {
|
|
9
|
+
// In no-worker-init mode the main process reports Vitest events from reporter hooks.
|
|
10
|
+
// Loading worker instrumentation here would reintroduce the worker tracer path.
|
|
11
|
+
// eslint-disable-next-line eslint-rules/eslint-process-env
|
|
12
|
+
if (isTrue(process.env[VITEST_NO_WORKER_INIT_ACTIVE_ENV])) return
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const testPassCh = channel('ci:vitest:test:pass')
|
|
23
|
-
const testErrorCh = channel('ci:vitest:test:error')
|
|
24
|
-
const testSkipCh = channel('ci:vitest:test:skip')
|
|
25
|
-
const isNewTestCh = channel('ci:vitest:test:is-new')
|
|
26
|
-
const isAttemptToFixCh = channel('ci:vitest:test:is-attempt-to-fix')
|
|
27
|
-
const isDisabledCh = channel('ci:vitest:test:is-disabled')
|
|
28
|
-
const isQuarantinedCh = channel('ci:vitest:test:is-quarantined')
|
|
29
|
-
const isModifiedCh = channel('ci:vitest:test:is-modified')
|
|
30
|
-
const testFnCh = channel('ci:vitest:test:fn')
|
|
31
|
-
|
|
32
|
-
// test suite hooks
|
|
33
|
-
const testSuiteStartCh = channel('ci:vitest:test-suite:start')
|
|
34
|
-
const testSuiteFinishCh = channel('ci:vitest:test-suite:finish')
|
|
35
|
-
const testSuiteErrorCh = channel('ci:vitest:test-suite:error')
|
|
36
|
-
|
|
37
|
-
// test session hooks
|
|
38
|
-
const testSessionStartCh = channel('ci:vitest:session:start')
|
|
39
|
-
const testSessionFinishCh = channel('ci:vitest:session:finish')
|
|
40
|
-
const libraryConfigurationCh = channel('ci:vitest:library-configuration')
|
|
41
|
-
const knownTestsCh = channel('ci:vitest:known-tests')
|
|
42
|
-
const isEarlyFlakeDetectionFaultyCh = channel('ci:vitest:is-early-flake-detection-faulty')
|
|
43
|
-
const testManagementTestsCh = channel('ci:vitest:test-management-tests')
|
|
44
|
-
const modifiedFilesCh = channel('ci:vitest:modified-files')
|
|
45
|
-
|
|
46
|
-
const workerReportTraceCh = channel('ci:vitest:worker-report:trace')
|
|
47
|
-
const workerReportLogsCh = channel('ci:vitest:worker-report:logs')
|
|
48
|
-
const codeCoverageReportCh = channel('ci:vitest:coverage-report')
|
|
49
|
-
|
|
50
|
-
const taskToCtx = new WeakMap()
|
|
51
|
-
const taskToStatuses = new WeakMap()
|
|
52
|
-
const originalHookFns = new WeakMap()
|
|
53
|
-
const newTasks = new WeakSet()
|
|
54
|
-
const dynamicNameTasks = new WeakSet()
|
|
55
|
-
const newTestsWithDynamicNames = new Set()
|
|
56
|
-
const disabledTasks = new WeakSet()
|
|
57
|
-
const quarantinedTasks = new WeakSet()
|
|
58
|
-
const attemptToFixTasks = new WeakSet()
|
|
59
|
-
const modifiedTasks = new WeakSet()
|
|
60
|
-
let isRetryReasonEfd = false
|
|
61
|
-
let isRetryReasonAttemptToFix = false
|
|
62
|
-
const switchedStatuses = new WeakSet()
|
|
63
|
-
const workerProcesses = new WeakSet()
|
|
64
|
-
let isFlakyTestRetriesEnabled = false
|
|
65
|
-
let flakyTestRetriesCount = 0
|
|
66
|
-
let isEarlyFlakeDetectionEnabled = false
|
|
67
|
-
let earlyFlakeDetectionNumRetries = 0
|
|
68
|
-
let isEarlyFlakeDetectionFaulty = false
|
|
69
|
-
let isKnownTestsEnabled = false
|
|
70
|
-
let isTestManagementTestsEnabled = false
|
|
71
|
-
let isImpactedTestsEnabled = false
|
|
72
|
-
let vitestGetFn = null
|
|
73
|
-
let vitestSetFn = null
|
|
74
|
-
let vitestGetHooks = null
|
|
75
|
-
let testManagementAttemptToFixRetries = 0
|
|
76
|
-
let isDiEnabled = false
|
|
77
|
-
let testCodeCoverageLinesTotal
|
|
78
|
-
let coverageRootDir
|
|
79
|
-
let isSessionStarted = false
|
|
80
|
-
let vitestPool = null
|
|
81
|
-
|
|
82
|
-
const BREAKPOINT_HIT_GRACE_PERIOD_MS = 400
|
|
83
|
-
|
|
84
|
-
function getTestCommand () {
|
|
85
|
-
return `vitest ${process.argv.slice(2).join(' ')}`
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function waitForHitProbe () {
|
|
89
|
-
return new Promise(resolve => {
|
|
90
|
-
realSetTimeout(() => {
|
|
91
|
-
resolve()
|
|
92
|
-
}, BREAKPOINT_HIT_GRACE_PERIOD_MS)
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function isValidKnownTests (receivedKnownTests) {
|
|
97
|
-
return !!receivedKnownTests.vitest
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function getProvidedContext () {
|
|
101
|
-
try {
|
|
102
|
-
const {
|
|
103
|
-
_ddIsEarlyFlakeDetectionEnabled,
|
|
104
|
-
_ddIsDiEnabled,
|
|
105
|
-
_ddKnownTests: knownTests,
|
|
106
|
-
_ddEarlyFlakeDetectionNumRetries: numRepeats,
|
|
107
|
-
_ddIsKnownTestsEnabled: isKnownTestsEnabled,
|
|
108
|
-
_ddIsTestManagementTestsEnabled: isTestManagementTestsEnabled,
|
|
109
|
-
_ddTestManagementAttemptToFixRetries: testManagementAttemptToFixRetries,
|
|
110
|
-
_ddTestManagementTests: testManagementTests,
|
|
111
|
-
_ddIsFlakyTestRetriesEnabled: isFlakyTestRetriesEnabled,
|
|
112
|
-
_ddFlakyTestRetriesCount: flakyTestRetriesCount,
|
|
113
|
-
_ddIsImpactedTestsEnabled: isImpactedTestsEnabled,
|
|
114
|
-
_ddModifiedFiles: modifiedFiles,
|
|
115
|
-
} = globalThis.__vitest_worker__.providedContext
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
isDiEnabled: _ddIsDiEnabled,
|
|
119
|
-
isEarlyFlakeDetectionEnabled: _ddIsEarlyFlakeDetectionEnabled,
|
|
120
|
-
knownTests,
|
|
121
|
-
numRepeats,
|
|
122
|
-
isKnownTestsEnabled,
|
|
123
|
-
isTestManagementTestsEnabled,
|
|
124
|
-
testManagementAttemptToFixRetries,
|
|
125
|
-
testManagementTests,
|
|
126
|
-
isFlakyTestRetriesEnabled,
|
|
127
|
-
flakyTestRetriesCount: flakyTestRetriesCount ?? 0,
|
|
128
|
-
isImpactedTestsEnabled,
|
|
129
|
-
modifiedFiles,
|
|
130
|
-
}
|
|
131
|
-
} catch {
|
|
132
|
-
log.error('Vitest workers could not parse provided context, so some features will not work.')
|
|
133
|
-
return {
|
|
134
|
-
isDiEnabled: false,
|
|
135
|
-
isEarlyFlakeDetectionEnabled: false,
|
|
136
|
-
knownTests: {},
|
|
137
|
-
numRepeats: 0,
|
|
138
|
-
isKnownTestsEnabled: false,
|
|
139
|
-
isTestManagementTestsEnabled: false,
|
|
140
|
-
testManagementAttemptToFixRetries: 0,
|
|
141
|
-
testManagementTests: {},
|
|
142
|
-
isFlakyTestRetriesEnabled: false,
|
|
143
|
-
flakyTestRetriesCount: 0,
|
|
144
|
-
isImpactedTestsEnabled: false,
|
|
145
|
-
modifiedFiles: {},
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function isReporterPackage (vitestPackage) {
|
|
151
|
-
return vitestPackage.B?.name === 'BaseSequencer'
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// from 2.0.0
|
|
155
|
-
function isReporterPackageNew (vitestPackage) {
|
|
156
|
-
return vitestPackage.e?.name === 'BaseSequencer'
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function isReporterPackageNewest (vitestPackage) {
|
|
160
|
-
return vitestPackage.h?.name === 'BaseSequencer'
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Finds an export by its `.name` property in a minified vitest chunk.
|
|
165
|
-
* Minified export keys change across versions, so we search by function/class name.
|
|
166
|
-
* @param {object} pkg - The module exports object
|
|
167
|
-
* @param {string} name - The `.name` value to look for
|
|
168
|
-
* @returns {{ key: string, value: Function } | undefined}
|
|
169
|
-
*/
|
|
170
|
-
function findExportByName (pkg, name) {
|
|
171
|
-
for (const [key, value] of Object.entries(pkg)) {
|
|
172
|
-
if (value?.name === name) {
|
|
173
|
-
return { key, value }
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function getBaseSequencerExport (vitestPackage) {
|
|
179
|
-
return findExportByName(vitestPackage, 'BaseSequencer')
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function getChannelPromise (channelToPublishTo, frameworkVersion) {
|
|
183
|
-
return new Promise(resolve => {
|
|
184
|
-
channelToPublishTo.publish({ onDone: resolve, frameworkVersion })
|
|
185
|
-
})
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function isCliApiPackage (vitestPackage) {
|
|
189
|
-
return !!findExportByName(vitestPackage, 'startVitest')
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function getTestRunnerExport (testPackage) {
|
|
193
|
-
return findExportByName(testPackage, 'VitestTestRunner') || findExportByName(testPackage, 'TestRunner')
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function getForksPoolWorkerExport (vitestPackage) {
|
|
197
|
-
return findExportByName(vitestPackage, 'ForksPoolWorker')
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function getThreadsPoolWorkerExport (vitestPackage) {
|
|
201
|
-
return findExportByName(vitestPackage, 'ThreadsPoolWorker')
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function getSessionStatus (state) {
|
|
205
|
-
if (state.getCountOfFailedTests() > 0) {
|
|
206
|
-
return 'fail'
|
|
207
|
-
}
|
|
208
|
-
if (state.pathsSet.size === 0) {
|
|
209
|
-
return 'skip'
|
|
210
|
-
}
|
|
211
|
-
return 'pass'
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// From https://github.com/vitest-dev/vitest/blob/51c04e2f44d91322b334f8ccbcdb368facc3f8ec/packages/runner/src/run.ts#L243-L250
|
|
215
|
-
function getVitestTestStatus (test, retryCount) {
|
|
216
|
-
if (test.result.state !== 'fail') {
|
|
217
|
-
if (!test.repeats) {
|
|
218
|
-
return 'pass'
|
|
219
|
-
} else if (test.repeats && (test.retry ?? 0) === retryCount) {
|
|
220
|
-
return 'pass'
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return 'fail'
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function getTypeTasks (fileTasks, type = 'test') {
|
|
227
|
-
const typeTasks = []
|
|
228
|
-
|
|
229
|
-
function getTasks (tasks) {
|
|
230
|
-
for (const task of tasks) {
|
|
231
|
-
if (task.type === type) {
|
|
232
|
-
typeTasks.push(task)
|
|
233
|
-
} else if (task.tasks) {
|
|
234
|
-
getTasks(task.tasks)
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
getTasks(fileTasks)
|
|
240
|
-
|
|
241
|
-
return typeTasks
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function getTestName (task) {
|
|
245
|
-
let testName = task.name
|
|
246
|
-
let currentTask = task.suite
|
|
247
|
-
|
|
248
|
-
while (currentTask) {
|
|
249
|
-
if (currentTask.name) {
|
|
250
|
-
testName = `${currentTask.name} ${testName}`
|
|
251
|
-
}
|
|
252
|
-
currentTask = currentTask.suite
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return testName
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Wraps a function so it runs inside the current test span context.
|
|
260
|
-
* @param {object} task
|
|
261
|
-
* @param {Function} fn
|
|
262
|
-
* @returns {Function}
|
|
263
|
-
*/
|
|
264
|
-
function wrapTestScopedFn (task, fn) {
|
|
265
|
-
return shimmer.wrapFunction(fn, fn => function () {
|
|
266
|
-
return testFnCh.runStores(taskToCtx.get(task), () => fn.apply(this, arguments))
|
|
267
|
-
})
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Wraps a `beforeEach` cleanup callback so it inherits the test span context.
|
|
272
|
-
* Vitest allows `beforeEach` to return a cleanup function, including via a promise.
|
|
273
|
-
* @param {object} task
|
|
274
|
-
* @param {unknown} result
|
|
275
|
-
* @returns {unknown}
|
|
276
|
-
*/
|
|
277
|
-
function wrapBeforeEachCleanupResult (task, result) {
|
|
278
|
-
if (typeof result === 'function') {
|
|
279
|
-
return wrapTestScopedFn(task, result)
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (result && typeof result.then === 'function') {
|
|
283
|
-
return result.then(cleanupFn => wrapBeforeEachCleanupResult(task, cleanupFn))
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
return result
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function getSortWrapper (sort, frameworkVersion) {
|
|
290
|
-
return async function () {
|
|
291
|
-
if (!testSessionFinishCh.hasSubscribers) {
|
|
292
|
-
return sort.apply(this, arguments)
|
|
293
|
-
}
|
|
294
|
-
// There isn't any other async function that we seem to be able to hook into
|
|
295
|
-
// So we will use the sort from BaseSequencer. This means that a custom sequencer
|
|
296
|
-
// will not work. This will be a known limitation.
|
|
297
|
-
|
|
298
|
-
try {
|
|
299
|
-
const { err, libraryConfig } = await getChannelPromise(libraryConfigurationCh, frameworkVersion)
|
|
300
|
-
if (!err) {
|
|
301
|
-
isFlakyTestRetriesEnabled = libraryConfig.isFlakyTestRetriesEnabled
|
|
302
|
-
flakyTestRetriesCount = libraryConfig.flakyTestRetriesCount
|
|
303
|
-
isEarlyFlakeDetectionEnabled = libraryConfig.isEarlyFlakeDetectionEnabled
|
|
304
|
-
earlyFlakeDetectionNumRetries = libraryConfig.earlyFlakeDetectionNumRetries
|
|
305
|
-
isDiEnabled = libraryConfig.isDiEnabled
|
|
306
|
-
isKnownTestsEnabled = libraryConfig.isKnownTestsEnabled
|
|
307
|
-
isTestManagementTestsEnabled = libraryConfig.isTestManagementEnabled
|
|
308
|
-
testManagementAttemptToFixRetries = libraryConfig.testManagementAttemptToFixRetries
|
|
309
|
-
isImpactedTestsEnabled = libraryConfig.isImpactedTestsEnabled
|
|
310
|
-
}
|
|
311
|
-
} catch {
|
|
312
|
-
isFlakyTestRetriesEnabled = false
|
|
313
|
-
isEarlyFlakeDetectionEnabled = false
|
|
314
|
-
isDiEnabled = false
|
|
315
|
-
isKnownTestsEnabled = false
|
|
316
|
-
isImpactedTestsEnabled = false
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (isFlakyTestRetriesEnabled && !this.ctx.config.retry && flakyTestRetriesCount > 0) {
|
|
320
|
-
this.ctx.config.retry = flakyTestRetriesCount
|
|
321
|
-
try {
|
|
322
|
-
const workspaceProject = this.ctx.getCoreWorkspaceProject
|
|
323
|
-
? this.ctx.getCoreWorkspaceProject()
|
|
324
|
-
: this.ctx.getRootProject()
|
|
325
|
-
workspaceProject._provided._ddIsFlakyTestRetriesEnabled = isFlakyTestRetriesEnabled
|
|
326
|
-
workspaceProject._provided._ddFlakyTestRetriesCount = flakyTestRetriesCount
|
|
327
|
-
} catch {
|
|
328
|
-
log.warn('Could not send library configuration to workers.')
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (isKnownTestsEnabled) {
|
|
333
|
-
const knownTestsResponse = await getChannelPromise(knownTestsCh)
|
|
334
|
-
if (knownTestsResponse.err) {
|
|
335
|
-
isEarlyFlakeDetectionEnabled = false
|
|
336
|
-
} else {
|
|
337
|
-
const knownTests = knownTestsResponse.knownTests
|
|
338
|
-
const getFilePaths = this.ctx.getTestFilepaths || this.ctx._globTestFilepaths
|
|
339
|
-
|
|
340
|
-
const testFilepaths = await getFilePaths.call(this.ctx)
|
|
341
|
-
|
|
342
|
-
if (isValidKnownTests(knownTests)) {
|
|
343
|
-
isEarlyFlakeDetectionFaultyCh.publish({
|
|
344
|
-
knownTests: knownTests.vitest,
|
|
345
|
-
testFilepaths,
|
|
346
|
-
onDone: (isFaulty) => {
|
|
347
|
-
isEarlyFlakeDetectionFaulty = isFaulty
|
|
348
|
-
},
|
|
349
|
-
})
|
|
350
|
-
if (isEarlyFlakeDetectionFaulty) {
|
|
351
|
-
isEarlyFlakeDetectionEnabled = false
|
|
352
|
-
log.warn('New test detection is disabled because the number of new tests is too high.')
|
|
353
|
-
} else {
|
|
354
|
-
// TODO: use this to pass session and module IDs to the worker, instead of polluting process.env
|
|
355
|
-
// Note: setting this.ctx.config.provide directly does not work because it's cached
|
|
356
|
-
try {
|
|
357
|
-
const workspaceProject = this.ctx.getCoreWorkspaceProject
|
|
358
|
-
? this.ctx.getCoreWorkspaceProject()
|
|
359
|
-
: this.ctx.getRootProject()
|
|
360
|
-
workspaceProject._provided._ddIsKnownTestsEnabled = isKnownTestsEnabled
|
|
361
|
-
workspaceProject._provided._ddKnownTests = knownTests
|
|
362
|
-
workspaceProject._provided._ddIsEarlyFlakeDetectionEnabled = isEarlyFlakeDetectionEnabled
|
|
363
|
-
workspaceProject._provided._ddEarlyFlakeDetectionNumRetries = earlyFlakeDetectionNumRetries
|
|
364
|
-
} catch {
|
|
365
|
-
log.warn('Could not send known tests to workers so Early Flake Detection will not work.')
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
} else {
|
|
369
|
-
isEarlyFlakeDetectionFaulty = true
|
|
370
|
-
isEarlyFlakeDetectionEnabled = false
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
if (isDiEnabled) {
|
|
376
|
-
try {
|
|
377
|
-
const workspaceProject = this.ctx.getCoreWorkspaceProject
|
|
378
|
-
? this.ctx.getCoreWorkspaceProject()
|
|
379
|
-
: this.ctx.getRootProject()
|
|
380
|
-
workspaceProject._provided._ddIsDiEnabled = isDiEnabled
|
|
381
|
-
} catch {
|
|
382
|
-
log.warn('Could not send Dynamic Instrumentation configuration to workers.')
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
if (isTestManagementTestsEnabled) {
|
|
387
|
-
const { err, testManagementTests: receivedTestManagementTests } = await getChannelPromise(testManagementTestsCh)
|
|
388
|
-
if (err) {
|
|
389
|
-
isTestManagementTestsEnabled = false
|
|
390
|
-
log.error('Could not get test management tests.')
|
|
391
|
-
} else {
|
|
392
|
-
const testManagementTests = receivedTestManagementTests
|
|
393
|
-
try {
|
|
394
|
-
const workspaceProject = this.ctx.getCoreWorkspaceProject
|
|
395
|
-
? this.ctx.getCoreWorkspaceProject()
|
|
396
|
-
: this.ctx.getRootProject()
|
|
397
|
-
workspaceProject._provided._ddIsTestManagementTestsEnabled = isTestManagementTestsEnabled
|
|
398
|
-
workspaceProject._provided._ddTestManagementAttemptToFixRetries = testManagementAttemptToFixRetries
|
|
399
|
-
workspaceProject._provided._ddTestManagementTests = testManagementTests
|
|
400
|
-
} catch {
|
|
401
|
-
log.warn('Could not send test management tests to workers so Test Management will not work.')
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
if (isImpactedTestsEnabled) {
|
|
407
|
-
const { err, modifiedFiles } = await getChannelPromise(modifiedFilesCh)
|
|
408
|
-
if (err) {
|
|
409
|
-
log.error('Could not get modified tests.')
|
|
410
|
-
} else {
|
|
411
|
-
try {
|
|
412
|
-
const workspaceProject = this.ctx.getCoreWorkspaceProject
|
|
413
|
-
? this.ctx.getCoreWorkspaceProject()
|
|
414
|
-
: this.ctx.getRootProject()
|
|
415
|
-
workspaceProject._provided._ddIsImpactedTestsEnabled = isImpactedTestsEnabled
|
|
416
|
-
workspaceProject._provided._ddModifiedFiles = modifiedFiles
|
|
417
|
-
} catch {
|
|
418
|
-
log.warn('Could not send modified tests to workers so Impacted Tests will not work.')
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
if (this.ctx.coverageProvider?.generateCoverage) {
|
|
424
|
-
// Capture coverage root directory from config (default is 'coverage' in cwd)
|
|
425
|
-
try {
|
|
426
|
-
const coverageConfig = this.ctx.config?.coverage
|
|
427
|
-
const reportsDirectory = coverageConfig?.reportsDirectory || 'coverage'
|
|
428
|
-
const rootDir = this.ctx.config?.root || process.cwd()
|
|
429
|
-
coverageRootDir = path.isAbsolute(reportsDirectory) ? reportsDirectory : path.join(rootDir, reportsDirectory)
|
|
430
|
-
} catch {
|
|
431
|
-
// Fallback to cwd if we can't get config
|
|
432
|
-
coverageRootDir = process.cwd()
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
shimmer.wrap(this.ctx.coverageProvider, 'generateCoverage', generateCoverage => async function () {
|
|
436
|
-
const totalCodeCoverage = await generateCoverage.apply(this, arguments)
|
|
437
|
-
|
|
438
|
-
try {
|
|
439
|
-
testCodeCoverageLinesTotal = totalCodeCoverage.getCoverageSummary().lines.pct
|
|
440
|
-
} catch {
|
|
441
|
-
// ignore errors
|
|
442
|
-
}
|
|
443
|
-
return totalCodeCoverage
|
|
444
|
-
})
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
shimmer.wrap(this.ctx, 'exit', getFinishWrapper)
|
|
448
|
-
shimmer.wrap(this.ctx, 'close', getFinishWrapper)
|
|
449
|
-
|
|
450
|
-
return sort.apply(this, arguments)
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
function getFinishWrapper (exitOrClose) {
|
|
455
|
-
let isClosed = false
|
|
456
|
-
return async function () {
|
|
457
|
-
if (isClosed) { // needed because exit calls close
|
|
458
|
-
return exitOrClose.apply(this, arguments)
|
|
459
|
-
}
|
|
460
|
-
isClosed = true
|
|
461
|
-
let onFinish
|
|
462
|
-
|
|
463
|
-
const flushPromise = new Promise(resolve => {
|
|
464
|
-
onFinish = resolve
|
|
465
|
-
})
|
|
466
|
-
const failedSuites = this.state.getFailedFilepaths()
|
|
467
|
-
let error
|
|
468
|
-
if (failedSuites.length) {
|
|
469
|
-
error = new Error(`Test suites failed: ${failedSuites.length}.`)
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
testSessionFinishCh.publish({
|
|
473
|
-
status: getSessionStatus(this.state),
|
|
474
|
-
testCodeCoverageLinesTotal,
|
|
475
|
-
error,
|
|
476
|
-
isEarlyFlakeDetectionEnabled,
|
|
477
|
-
isEarlyFlakeDetectionFaulty,
|
|
478
|
-
isTestManagementTestsEnabled,
|
|
479
|
-
vitestPool,
|
|
480
|
-
onFinish,
|
|
481
|
-
})
|
|
482
|
-
|
|
483
|
-
logDynamicNamesWarning(newTestsWithDynamicNames)
|
|
484
|
-
|
|
485
|
-
await flushPromise
|
|
486
|
-
|
|
487
|
-
// If coverage was generated, publish coverage report channel for upload
|
|
488
|
-
if (coverageRootDir && codeCoverageReportCh.hasSubscribers) {
|
|
489
|
-
await new Promise((resolve) => {
|
|
490
|
-
codeCoverageReportCh.publish({ rootDir: coverageRootDir, onDone: resolve })
|
|
491
|
-
})
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
return exitOrClose.apply(this, arguments)
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
function getCliOrStartVitestWrapper (frameworkVersion) {
|
|
499
|
-
return function (oldCliOrStartVitest) {
|
|
500
|
-
return function () {
|
|
501
|
-
if (!testSessionStartCh.hasSubscribers || isSessionStarted) {
|
|
502
|
-
return oldCliOrStartVitest.apply(this, arguments)
|
|
503
|
-
}
|
|
504
|
-
isSessionStarted = true
|
|
505
|
-
testSessionStartCh.publish({ command: getTestCommand(), frameworkVersion })
|
|
506
|
-
return oldCliOrStartVitest.apply(this, arguments)
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
function getCreateCliWrapper (vitestPackage, frameworkVersion) {
|
|
512
|
-
const createCliExport = findExportByName(vitestPackage, 'createCLI')
|
|
513
|
-
if (!createCliExport) {
|
|
514
|
-
return vitestPackage
|
|
515
|
-
}
|
|
516
|
-
shimmer.wrap(vitestPackage, createCliExport.key, getCliOrStartVitestWrapper(frameworkVersion))
|
|
517
|
-
|
|
518
|
-
return vitestPackage
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
function threadHandler (thread) {
|
|
522
|
-
const { runtime } = thread
|
|
523
|
-
let workerProcess
|
|
524
|
-
if (runtime === 'child_process') {
|
|
525
|
-
vitestPool = 'child_process'
|
|
526
|
-
workerProcess = thread.process
|
|
527
|
-
} else if (runtime === 'worker_threads') {
|
|
528
|
-
vitestPool = 'worker_threads'
|
|
529
|
-
workerProcess = thread.thread
|
|
530
|
-
} else {
|
|
531
|
-
vitestPool = 'unknown'
|
|
532
|
-
}
|
|
533
|
-
if (!workerProcess) {
|
|
534
|
-
log.error('Vitest error: could not get process or thread from TinyPool#run')
|
|
535
|
-
return
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
if (workerProcesses.has(workerProcess)) {
|
|
539
|
-
return
|
|
540
|
-
}
|
|
541
|
-
workerProcesses.add(workerProcess)
|
|
542
|
-
workerProcess.on('message', (message) => {
|
|
543
|
-
if (message.__tinypool_worker_message__ && message.data) {
|
|
544
|
-
if (message.interprocessCode === VITEST_WORKER_TRACE_PAYLOAD_CODE) {
|
|
545
|
-
collectDynamicNamesFromTraces(message.data, newTestsWithDynamicNames)
|
|
546
|
-
workerReportTraceCh.publish(message.data)
|
|
547
|
-
} else if (message.interprocessCode === VITEST_WORKER_LOGS_PAYLOAD_CODE) {
|
|
548
|
-
workerReportLogsCh.publish(message.data)
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
})
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
function wrapTinyPoolRun (TinyPool) {
|
|
555
|
-
shimmer.wrap(TinyPool.prototype, 'run', run => async function () {
|
|
556
|
-
// We have to do this before and after because the threads list gets recycled, that is, the processes are re-created
|
|
557
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
558
|
-
this.threads.forEach(threadHandler)
|
|
559
|
-
const runResult = await run.apply(this, arguments)
|
|
560
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
561
|
-
this.threads.forEach(threadHandler)
|
|
562
|
-
return runResult
|
|
563
|
-
})
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
addHook({
|
|
567
|
-
name: 'tinypool',
|
|
568
|
-
// version from tinypool@0.8 was used in vitest@1.6.0
|
|
569
|
-
versions: ['>=0.8.0'],
|
|
570
|
-
}, (TinyPool) => {
|
|
571
|
-
wrapTinyPoolRun(TinyPool)
|
|
572
|
-
return TinyPool
|
|
573
|
-
})
|
|
574
|
-
|
|
575
|
-
function getWrappedOn (on) {
|
|
576
|
-
return function (event, callback) {
|
|
577
|
-
if (event !== 'message') {
|
|
578
|
-
return on.apply(this, arguments)
|
|
579
|
-
}
|
|
580
|
-
// `arguments[1]` is the callback function, which
|
|
581
|
-
// we modify to intercept our messages to not interfere
|
|
582
|
-
// with vitest's own messages
|
|
583
|
-
arguments[1] = shimmer.wrapFunction(callback, callback => function (message) {
|
|
584
|
-
if (message.type !== 'Buffer' && Array.isArray(message)) {
|
|
585
|
-
const [interprocessCode, data] = message
|
|
586
|
-
if (interprocessCode === VITEST_WORKER_TRACE_PAYLOAD_CODE) {
|
|
587
|
-
collectDynamicNamesFromTraces(data, newTestsWithDynamicNames)
|
|
588
|
-
workerReportTraceCh.publish(data)
|
|
589
|
-
} else if (interprocessCode === VITEST_WORKER_LOGS_PAYLOAD_CODE) {
|
|
590
|
-
workerReportLogsCh.publish(data)
|
|
591
|
-
}
|
|
592
|
-
// If we execute the callback vitest crashes, as the message is not supported
|
|
593
|
-
return
|
|
594
|
-
}
|
|
595
|
-
return callback.apply(this, arguments)
|
|
596
|
-
})
|
|
597
|
-
return on.apply(this, arguments)
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
function getStartVitestWrapper (cliApiPackage, frameworkVersion) {
|
|
602
|
-
if (!isCliApiPackage(cliApiPackage)) {
|
|
603
|
-
return cliApiPackage
|
|
604
|
-
}
|
|
605
|
-
const startVitestExport = findExportByName(cliApiPackage, 'startVitest')
|
|
606
|
-
shimmer.wrap(cliApiPackage, startVitestExport.key, getCliOrStartVitestWrapper(frameworkVersion))
|
|
607
|
-
|
|
608
|
-
const forksPoolWorker = getForksPoolWorkerExport(cliApiPackage)
|
|
609
|
-
if (forksPoolWorker) {
|
|
610
|
-
// function is async
|
|
611
|
-
shimmer.wrap(forksPoolWorker.value.prototype, 'start', start => function () {
|
|
612
|
-
vitestPool = 'child_process'
|
|
613
|
-
this.env.DD_VITEST_WORKER = '1'
|
|
614
|
-
|
|
615
|
-
return start.apply(this, arguments)
|
|
616
|
-
})
|
|
617
|
-
shimmer.wrap(forksPoolWorker.value.prototype, 'on', getWrappedOn)
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
const threadsPoolWorker = getThreadsPoolWorkerExport(cliApiPackage)
|
|
621
|
-
if (threadsPoolWorker) {
|
|
622
|
-
// function is async
|
|
623
|
-
shimmer.wrap(threadsPoolWorker.value.prototype, 'start', start => function () {
|
|
624
|
-
vitestPool = 'worker_threads'
|
|
625
|
-
this.env.DD_VITEST_WORKER = '1'
|
|
626
|
-
return start.apply(this, arguments)
|
|
627
|
-
})
|
|
628
|
-
shimmer.wrap(threadsPoolWorker.value.prototype, 'on', getWrappedOn)
|
|
629
|
-
}
|
|
630
|
-
return cliApiPackage
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
function wrapVitestTestRunner (VitestTestRunner) {
|
|
634
|
-
// `onBeforeRunTask` is run before any repetition or attempt is run
|
|
635
|
-
// `onBeforeRunTask` is an async function
|
|
636
|
-
shimmer.wrap(VitestTestRunner.prototype, 'onBeforeRunTask', onBeforeRunTask => function (task) {
|
|
637
|
-
const testName = getTestName(task)
|
|
638
|
-
|
|
639
|
-
const {
|
|
640
|
-
knownTests,
|
|
641
|
-
isEarlyFlakeDetectionEnabled,
|
|
642
|
-
isKnownTestsEnabled,
|
|
643
|
-
numRepeats,
|
|
644
|
-
isTestManagementTestsEnabled,
|
|
645
|
-
testManagementAttemptToFixRetries,
|
|
646
|
-
testManagementTests,
|
|
647
|
-
isImpactedTestsEnabled,
|
|
648
|
-
modifiedFiles,
|
|
649
|
-
} = getProvidedContext()
|
|
650
|
-
|
|
651
|
-
if (isTestManagementTestsEnabled) {
|
|
652
|
-
isAttemptToFixCh.publish({
|
|
653
|
-
testManagementTests,
|
|
654
|
-
testSuiteAbsolutePath: task.file.filepath,
|
|
655
|
-
testName,
|
|
656
|
-
onDone: (isAttemptToFix) => {
|
|
657
|
-
if (isAttemptToFix) {
|
|
658
|
-
isRetryReasonAttemptToFix = task.repeats !== testManagementAttemptToFixRetries
|
|
659
|
-
task.repeats = testManagementAttemptToFixRetries
|
|
660
|
-
attemptToFixTasks.add(task)
|
|
661
|
-
taskToStatuses.set(task, [])
|
|
662
|
-
}
|
|
663
|
-
},
|
|
664
|
-
})
|
|
665
|
-
isDisabledCh.publish({
|
|
666
|
-
testManagementTests,
|
|
667
|
-
testSuiteAbsolutePath: task.file.filepath,
|
|
668
|
-
testName,
|
|
669
|
-
onDone: (isTestDisabled) => {
|
|
670
|
-
if (isTestDisabled) {
|
|
671
|
-
disabledTasks.add(task)
|
|
672
|
-
if (!attemptToFixTasks.has(task)) {
|
|
673
|
-
// we only actually skip if the test is not being attempted to be fixed
|
|
674
|
-
task.mode = 'skip'
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
},
|
|
678
|
-
})
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
if (isImpactedTestsEnabled) {
|
|
682
|
-
isModifiedCh.publish({
|
|
683
|
-
modifiedFiles,
|
|
684
|
-
testSuiteAbsolutePath: task.file.filepath,
|
|
685
|
-
onDone: (isImpacted) => {
|
|
686
|
-
if (isImpacted) {
|
|
687
|
-
if (isEarlyFlakeDetectionEnabled) {
|
|
688
|
-
isRetryReasonEfd = task.repeats !== numRepeats
|
|
689
|
-
task.repeats = numRepeats
|
|
690
|
-
}
|
|
691
|
-
modifiedTasks.add(task)
|
|
692
|
-
taskToStatuses.set(task, [])
|
|
693
|
-
}
|
|
694
|
-
},
|
|
695
|
-
})
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
if (isKnownTestsEnabled) {
|
|
699
|
-
isNewTestCh.publish({
|
|
700
|
-
knownTests,
|
|
701
|
-
testSuiteAbsolutePath: task.file.filepath,
|
|
702
|
-
testName,
|
|
703
|
-
onDone: (isNew) => {
|
|
704
|
-
if (isNew && !attemptToFixTasks.has(task)) {
|
|
705
|
-
if (isEarlyFlakeDetectionEnabled && !modifiedTasks.has(task)) {
|
|
706
|
-
isRetryReasonEfd = task.repeats !== numRepeats
|
|
707
|
-
task.repeats = numRepeats
|
|
708
|
-
}
|
|
709
|
-
newTasks.add(task)
|
|
710
|
-
taskToStatuses.set(task, [])
|
|
711
|
-
if (DYNAMIC_NAME_RE.test(testName)) {
|
|
712
|
-
dynamicNameTasks.add(task)
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
},
|
|
716
|
-
})
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
return onBeforeRunTask.apply(this, arguments)
|
|
720
|
-
})
|
|
721
|
-
|
|
722
|
-
// `onAfterRunTask` is run after all repetitions or attempts are run
|
|
723
|
-
// `onAfterRunTask` is an async function
|
|
724
|
-
shimmer.wrap(VitestTestRunner.prototype, 'onAfterRunTask', onAfterRunTask => function (task) {
|
|
725
|
-
const { isEarlyFlakeDetectionEnabled, isTestManagementTestsEnabled } = getProvidedContext()
|
|
726
|
-
|
|
727
|
-
if (isTestManagementTestsEnabled) {
|
|
728
|
-
const isAttemptingToFix = attemptToFixTasks.has(task)
|
|
729
|
-
const isDisabled = disabledTasks.has(task)
|
|
730
|
-
const isQuarantined = quarantinedTasks.has(task)
|
|
731
|
-
|
|
732
|
-
if (isAttemptingToFix && (isDisabled || isQuarantined)) {
|
|
733
|
-
if (task.result.state === 'fail') {
|
|
734
|
-
switchedStatuses.add(task)
|
|
735
|
-
}
|
|
736
|
-
task.result.state = 'pass'
|
|
737
|
-
} else if (isQuarantined) {
|
|
738
|
-
if (task.result.state === 'fail') {
|
|
739
|
-
switchedStatuses.add(task)
|
|
740
|
-
}
|
|
741
|
-
task.result.state = 'pass'
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
if (isEarlyFlakeDetectionEnabled && taskToStatuses.has(task) && !attemptToFixTasks.has(task)) {
|
|
746
|
-
const statuses = taskToStatuses.get(task)
|
|
747
|
-
// If the test has passed at least once, we consider it passed
|
|
748
|
-
if (statuses.includes('pass')) {
|
|
749
|
-
if (task.result.state === 'fail') {
|
|
750
|
-
switchedStatuses.add(task)
|
|
751
|
-
}
|
|
752
|
-
task.result.state = 'pass'
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
return onAfterRunTask.apply(this, arguments)
|
|
757
|
-
})
|
|
758
|
-
|
|
759
|
-
// test start (only tests that are not marked as skip or todo)
|
|
760
|
-
// `onBeforeTryTask` is run for every repetition and attempt of the test
|
|
761
|
-
shimmer.wrap(VitestTestRunner.prototype, 'onBeforeTryTask', onBeforeTryTask => async function (task, retryInfo) {
|
|
762
|
-
if (!testPassCh.hasSubscribers && !testErrorCh.hasSubscribers && !testSkipCh.hasSubscribers) {
|
|
763
|
-
return onBeforeTryTask.apply(this, arguments)
|
|
764
|
-
}
|
|
765
|
-
const testName = getTestName(task)
|
|
766
|
-
let isNew = false
|
|
767
|
-
let isQuarantined = false
|
|
768
|
-
|
|
769
|
-
const {
|
|
770
|
-
isKnownTestsEnabled,
|
|
771
|
-
isEarlyFlakeDetectionEnabled,
|
|
772
|
-
isDiEnabled,
|
|
773
|
-
isTestManagementTestsEnabled,
|
|
774
|
-
testManagementTests,
|
|
775
|
-
isFlakyTestRetriesEnabled,
|
|
776
|
-
} = getProvidedContext()
|
|
777
|
-
|
|
778
|
-
if (isKnownTestsEnabled) {
|
|
779
|
-
isNew = newTasks.has(task)
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
if (isTestManagementTestsEnabled) {
|
|
783
|
-
isQuarantinedCh.publish({
|
|
784
|
-
testManagementTests,
|
|
785
|
-
testSuiteAbsolutePath: task.file.filepath,
|
|
786
|
-
testName,
|
|
787
|
-
onDone: (isTestQuarantined) => {
|
|
788
|
-
isQuarantined = isTestQuarantined
|
|
789
|
-
if (isTestQuarantined) {
|
|
790
|
-
quarantinedTasks.add(task)
|
|
791
|
-
}
|
|
792
|
-
},
|
|
793
|
-
})
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
const { retry: numAttempt, repeats: numRepetition } = retryInfo
|
|
797
|
-
|
|
798
|
-
// We finish the previous test here because we know it has failed already
|
|
799
|
-
if (numAttempt > 0) {
|
|
800
|
-
const shouldWaitForHitProbe = isDiEnabled && numAttempt > 1
|
|
801
|
-
if (shouldWaitForHitProbe) {
|
|
802
|
-
await waitForHitProbe()
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
const promises = {}
|
|
806
|
-
const shouldSetProbe = isDiEnabled && numAttempt === 1
|
|
807
|
-
const ctx = taskToCtx.get(task)
|
|
808
|
-
const testError = task.result?.errors?.[0]
|
|
809
|
-
if (ctx) {
|
|
810
|
-
testErrorCh.publish({
|
|
811
|
-
error: testError,
|
|
812
|
-
shouldSetProbe,
|
|
813
|
-
promises,
|
|
814
|
-
...ctx.currentStore,
|
|
815
|
-
})
|
|
816
|
-
// We wait for the probe to be set
|
|
817
|
-
if (promises.setProbePromise) {
|
|
818
|
-
await promises.setProbePromise
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
const lastExecutionStatus = task.result.state
|
|
824
|
-
const isAtf = attemptToFixTasks.has(task)
|
|
825
|
-
const isQuarantinedOrDisabledAtf = isAtf && (quarantinedTasks.has(task) || disabledTasks.has(task))
|
|
826
|
-
const shouldTrackStatuses = isEarlyFlakeDetectionEnabled || isAtf
|
|
827
|
-
const shouldFlipStatus = isEarlyFlakeDetectionEnabled || isQuarantinedOrDisabledAtf
|
|
828
|
-
const statuses = taskToStatuses.get(task)
|
|
829
|
-
|
|
830
|
-
// These clauses handle task.repeats, whether EFD is enabled or not
|
|
831
|
-
// The only thing that EFD does is to forcefully pass the test if it has passed at least once
|
|
832
|
-
if (numRepetition > 0 && numRepetition < task.repeats) { // it may or may have not failed
|
|
833
|
-
// Here we finish the earlier iteration,
|
|
834
|
-
// as long as it's not the _last_ iteration (which will be finished normally)
|
|
835
|
-
|
|
836
|
-
// TODO: check test duration (not to repeat if it's too slow)
|
|
837
|
-
const ctx = taskToCtx.get(task)
|
|
838
|
-
if (ctx) {
|
|
839
|
-
if (lastExecutionStatus === 'fail') {
|
|
840
|
-
const testError = task.result?.errors?.[0]
|
|
841
|
-
testErrorCh.publish({ error: testError, ...ctx.currentStore })
|
|
842
|
-
} else {
|
|
843
|
-
testPassCh.publish({ task, ...ctx.currentStore })
|
|
844
|
-
}
|
|
845
|
-
if (shouldTrackStatuses) {
|
|
846
|
-
statuses.push(lastExecutionStatus)
|
|
847
|
-
}
|
|
848
|
-
if (shouldFlipStatus) {
|
|
849
|
-
// If we don't "reset" the result.state to "pass", once a repetition fails,
|
|
850
|
-
// vitest will always consider the test as failed, so we can't read the actual status
|
|
851
|
-
// This means that we change vitest's behavior:
|
|
852
|
-
// if the last attempt passes, vitest would consider the test as failed
|
|
853
|
-
// but after this change, it will consider the test as passed
|
|
854
|
-
task.result.state = 'pass'
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
} else if (numRepetition === task.repeats) {
|
|
858
|
-
if (shouldTrackStatuses) {
|
|
859
|
-
statuses.push(lastExecutionStatus)
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
const ctx = taskToCtx.get(task)
|
|
863
|
-
if (lastExecutionStatus === 'fail') {
|
|
864
|
-
const testError = task.result?.errors?.[0]
|
|
865
|
-
testErrorCh.publish({ error: testError, ...ctx.currentStore })
|
|
866
|
-
} else {
|
|
867
|
-
testPassCh.publish({ task, ...ctx.currentStore })
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
const isRetryReasonAtr = numAttempt > 0 &&
|
|
872
|
-
isFlakyTestRetriesEnabled &&
|
|
873
|
-
!isRetryReasonAttemptToFix &&
|
|
874
|
-
!isRetryReasonEfd
|
|
875
|
-
|
|
876
|
-
const ctx = {
|
|
877
|
-
testName,
|
|
878
|
-
testSuiteAbsolutePath: task.file.filepath,
|
|
879
|
-
isRetry: numAttempt > 0 || numRepetition > 0,
|
|
880
|
-
isRetryReasonEfd,
|
|
881
|
-
isRetryReasonAttemptToFix: isRetryReasonAttemptToFix && numRepetition > 0,
|
|
882
|
-
isNew,
|
|
883
|
-
hasDynamicName: dynamicNameTasks.has(task),
|
|
884
|
-
mightHitProbe: isDiEnabled && numAttempt > 0,
|
|
885
|
-
isAttemptToFix: attemptToFixTasks.has(task),
|
|
886
|
-
isDisabled: disabledTasks.has(task),
|
|
887
|
-
isQuarantined,
|
|
888
|
-
isRetryReasonAtr,
|
|
889
|
-
isModified: modifiedTasks.has(task),
|
|
890
|
-
}
|
|
891
|
-
taskToCtx.set(task, ctx)
|
|
892
|
-
|
|
893
|
-
testStartCh.runStores(ctx, () => {})
|
|
894
|
-
|
|
895
|
-
// Wrap the test function so it runs inside the test span context.
|
|
896
|
-
// Without this, HTTP requests during test execution become orphaned root spans.
|
|
897
|
-
if (vitestGetFn && vitestSetFn) {
|
|
898
|
-
const originalFn = vitestGetFn(task)
|
|
899
|
-
if (originalFn && !originalFn.__ddTraceWrapped) {
|
|
900
|
-
const wrappedFn = wrapTestScopedFn(task, originalFn)
|
|
901
|
-
wrappedFn.__ddTraceWrapped = true
|
|
902
|
-
vitestSetFn(task, wrappedFn)
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
// Wrap beforeEach/afterEach hooks so they also run inside the test span context.
|
|
907
|
-
// In vitest 4+, hooks are in a WeakMap accessed via getHooks(). In older versions, they're on suite.hooks.
|
|
908
|
-
let currentSuite = task.suite
|
|
909
|
-
while (currentSuite) {
|
|
910
|
-
const hooks = vitestGetHooks ? vitestGetHooks(currentSuite) : currentSuite.hooks
|
|
911
|
-
if (hooks) {
|
|
912
|
-
for (const hookType of ['beforeEach', 'afterEach']) {
|
|
913
|
-
const hookArray = hooks[hookType]
|
|
914
|
-
if (!hookArray) continue
|
|
915
|
-
for (let i = 0; i < hookArray.length; i++) {
|
|
916
|
-
const currentFn = hookArray[i]
|
|
917
|
-
const originalFn = originalHookFns.get(currentFn) || currentFn
|
|
918
|
-
const wrappedFn = shimmer.wrapFunction(originalFn, fn => function () {
|
|
919
|
-
const result = testFnCh.runStores(taskToCtx.get(task), () => fn.apply(this, arguments))
|
|
920
|
-
|
|
921
|
-
if (hookType === 'beforeEach') {
|
|
922
|
-
return wrapBeforeEachCleanupResult(task, result)
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
return result
|
|
926
|
-
})
|
|
927
|
-
originalHookFns.set(wrappedFn, originalFn)
|
|
928
|
-
hookArray[i] = wrappedFn
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
currentSuite = currentSuite.suite
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
return onBeforeTryTask.apply(this, arguments)
|
|
936
|
-
})
|
|
937
|
-
|
|
938
|
-
// test finish (only passed tests)
|
|
939
|
-
shimmer.wrap(VitestTestRunner.prototype, 'onAfterTryTask', onAfterTryTask =>
|
|
940
|
-
async function (task, { retry: retryCount }) {
|
|
941
|
-
if (!testPassCh.hasSubscribers && !testErrorCh.hasSubscribers && !testSkipCh.hasSubscribers) {
|
|
942
|
-
return onAfterTryTask.apply(this, arguments)
|
|
943
|
-
}
|
|
944
|
-
const result = await onAfterTryTask.apply(this, arguments)
|
|
945
|
-
|
|
946
|
-
const { testManagementAttemptToFixRetries } = getProvidedContext()
|
|
947
|
-
|
|
948
|
-
const status = getVitestTestStatus(task, retryCount)
|
|
949
|
-
const ctx = taskToCtx.get(task)
|
|
950
|
-
|
|
951
|
-
const { isDiEnabled } = getProvidedContext()
|
|
952
|
-
|
|
953
|
-
if (isDiEnabled && retryCount > 1) {
|
|
954
|
-
await waitForHitProbe()
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
let attemptToFixPassed = false
|
|
958
|
-
let attemptToFixFailed = false
|
|
959
|
-
if (attemptToFixTasks.has(task)) {
|
|
960
|
-
const statuses = taskToStatuses.get(task)
|
|
961
|
-
if (statuses.length === testManagementAttemptToFixRetries) {
|
|
962
|
-
if (statuses.every(status => status === 'pass')) {
|
|
963
|
-
attemptToFixPassed = true
|
|
964
|
-
} else if (statuses.includes('fail')) {
|
|
965
|
-
attemptToFixFailed = true
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
if (ctx) {
|
|
971
|
-
// We don't finish here because the test might fail in a later hook (afterEach)
|
|
972
|
-
ctx.status = status
|
|
973
|
-
ctx.task = task
|
|
974
|
-
ctx.attemptToFixPassed = attemptToFixPassed
|
|
975
|
-
ctx.attemptToFixFailed = attemptToFixFailed
|
|
976
|
-
testFinishTimeCh.runStores(ctx, () => {})
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
return result
|
|
980
|
-
})
|
|
14
|
+
require('./vitest-worker')
|
|
15
|
+
} else {
|
|
16
|
+
require('./vitest-main')
|
|
981
17
|
}
|
|
982
|
-
|
|
983
|
-
function captureRunnerFunctions (pkg) {
|
|
984
|
-
if (vitestGetFn) return
|
|
985
|
-
const getFnExport = findExportByName(pkg, 'getFn')
|
|
986
|
-
const setFnExport = findExportByName(pkg, 'setFn')
|
|
987
|
-
if (getFnExport && setFnExport) {
|
|
988
|
-
vitestGetFn = getFnExport.value
|
|
989
|
-
vitestSetFn = setFnExport.value
|
|
990
|
-
}
|
|
991
|
-
const getHooksExport = findExportByName(pkg, 'getHooks')
|
|
992
|
-
if (getHooksExport) {
|
|
993
|
-
vitestGetHooks = getHooksExport.value
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
addHook({
|
|
998
|
-
name: 'vitest',
|
|
999
|
-
versions: ['>=4.0.0'],
|
|
1000
|
-
filePattern: 'dist/chunks/test.*',
|
|
1001
|
-
}, (testPackage) => {
|
|
1002
|
-
const testRunner = getTestRunnerExport(testPackage)
|
|
1003
|
-
if (!testRunner) {
|
|
1004
|
-
return testPackage
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
captureRunnerFunctions(testPackage)
|
|
1008
|
-
wrapVitestTestRunner(testRunner.value)
|
|
1009
|
-
|
|
1010
|
-
return testPackage
|
|
1011
|
-
})
|
|
1012
|
-
|
|
1013
|
-
addHook({
|
|
1014
|
-
name: '@vitest/runner',
|
|
1015
|
-
versions: ['>=1.6.0'],
|
|
1016
|
-
}, (runnerModule) => {
|
|
1017
|
-
if (!vitestGetFn && runnerModule.getFn && runnerModule.setFn) {
|
|
1018
|
-
vitestGetFn = runnerModule.getFn
|
|
1019
|
-
vitestSetFn = runnerModule.setFn
|
|
1020
|
-
}
|
|
1021
|
-
if (!vitestGetHooks && runnerModule.getHooks) {
|
|
1022
|
-
vitestGetHooks = runnerModule.getHooks
|
|
1023
|
-
}
|
|
1024
|
-
return runnerModule
|
|
1025
|
-
})
|
|
1026
|
-
|
|
1027
|
-
addHook({
|
|
1028
|
-
name: 'vitest',
|
|
1029
|
-
versions: ['>=1.6.0 <4.0.0'],
|
|
1030
|
-
file: 'dist/runners.js',
|
|
1031
|
-
}, (vitestPackage) => {
|
|
1032
|
-
const { VitestTestRunner } = vitestPackage
|
|
1033
|
-
|
|
1034
|
-
wrapVitestTestRunner(VitestTestRunner)
|
|
1035
|
-
|
|
1036
|
-
return vitestPackage
|
|
1037
|
-
})
|
|
1038
|
-
|
|
1039
|
-
// There are multiple index* files across different versions of vitest,
|
|
1040
|
-
// so we check for the existence of BaseSequencer to determine if we are in the right file
|
|
1041
|
-
addHook({
|
|
1042
|
-
name: 'vitest',
|
|
1043
|
-
versions: ['>=1.6.0 <2.0.0'],
|
|
1044
|
-
filePattern: 'dist/vendor/index.*',
|
|
1045
|
-
}, (vitestPackage) => {
|
|
1046
|
-
if (isReporterPackage(vitestPackage)) {
|
|
1047
|
-
shimmer.wrap(vitestPackage.B.prototype, 'sort', getSortWrapper)
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
return vitestPackage
|
|
1051
|
-
})
|
|
1052
|
-
|
|
1053
|
-
addHook({
|
|
1054
|
-
name: 'vitest',
|
|
1055
|
-
versions: ['>=2.0.0 <2.0.5'],
|
|
1056
|
-
filePattern: 'dist/vendor/index.*',
|
|
1057
|
-
}, (vitestPackage) => {
|
|
1058
|
-
if (isReporterPackageNew(vitestPackage)) {
|
|
1059
|
-
shimmer.wrap(vitestPackage.e.prototype, 'sort', getSortWrapper)
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
return vitestPackage
|
|
1063
|
-
})
|
|
1064
|
-
|
|
1065
|
-
addHook({
|
|
1066
|
-
name: 'vitest',
|
|
1067
|
-
versions: ['>=2.0.5 <2.1.0'],
|
|
1068
|
-
filePattern: 'dist/chunks/index.*',
|
|
1069
|
-
}, (vitestPackage) => {
|
|
1070
|
-
if (isReporterPackageNewest(vitestPackage)) {
|
|
1071
|
-
shimmer.wrap(vitestPackage.h.prototype, 'sort', getSortWrapper)
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
return vitestPackage
|
|
1075
|
-
})
|
|
1076
|
-
|
|
1077
|
-
addHook({
|
|
1078
|
-
name: 'vitest',
|
|
1079
|
-
versions: ['>=2.1.0 <3.0.0'],
|
|
1080
|
-
filePattern: 'dist/chunks/RandomSequencer.*',
|
|
1081
|
-
}, (randomSequencerPackage) => {
|
|
1082
|
-
shimmer.wrap(randomSequencerPackage.B.prototype, 'sort', getSortWrapper)
|
|
1083
|
-
return randomSequencerPackage
|
|
1084
|
-
})
|
|
1085
|
-
|
|
1086
|
-
addHook({
|
|
1087
|
-
name: 'vitest',
|
|
1088
|
-
versions: ['>=3.0.9'],
|
|
1089
|
-
filePattern: 'dist/chunks/coverage.*',
|
|
1090
|
-
}, (coveragePackage) => {
|
|
1091
|
-
const baseSequencer = getBaseSequencerExport(coveragePackage)
|
|
1092
|
-
if (baseSequencer) {
|
|
1093
|
-
shimmer.wrap(baseSequencer.value.prototype, 'sort', getSortWrapper)
|
|
1094
|
-
}
|
|
1095
|
-
return coveragePackage
|
|
1096
|
-
})
|
|
1097
|
-
|
|
1098
|
-
addHook({
|
|
1099
|
-
name: 'vitest',
|
|
1100
|
-
versions: ['>=3.0.0 <3.0.9'],
|
|
1101
|
-
filePattern: 'dist/chunks/resolveConfig.*',
|
|
1102
|
-
}, (resolveConfigPackage) => {
|
|
1103
|
-
shimmer.wrap(resolveConfigPackage.B.prototype, 'sort', getSortWrapper)
|
|
1104
|
-
return resolveConfigPackage
|
|
1105
|
-
})
|
|
1106
|
-
|
|
1107
|
-
// Can't specify file because compiled vitest includes hashes in their files
|
|
1108
|
-
// Following 3 wrappers are for test session start
|
|
1109
|
-
addHook({
|
|
1110
|
-
name: 'vitest',
|
|
1111
|
-
versions: ['>=1.6.0 <2.0.5'],
|
|
1112
|
-
filePattern: 'dist/vendor/cac.*',
|
|
1113
|
-
}, getCreateCliWrapper)
|
|
1114
|
-
|
|
1115
|
-
addHook({
|
|
1116
|
-
name: 'vitest',
|
|
1117
|
-
versions: ['>=2.0.5'],
|
|
1118
|
-
filePattern: 'dist/chunks/cac.*',
|
|
1119
|
-
}, getCreateCliWrapper)
|
|
1120
|
-
|
|
1121
|
-
addHook({
|
|
1122
|
-
name: 'vitest',
|
|
1123
|
-
versions: ['>=1.6.0 <2.0.5'],
|
|
1124
|
-
filePattern: 'dist/vendor/cli-api.*',
|
|
1125
|
-
}, getStartVitestWrapper)
|
|
1126
|
-
|
|
1127
|
-
addHook({
|
|
1128
|
-
name: 'vitest',
|
|
1129
|
-
versions: ['>=2.0.5'],
|
|
1130
|
-
filePattern: 'dist/chunks/cli-api.*',
|
|
1131
|
-
}, getStartVitestWrapper)
|
|
1132
|
-
|
|
1133
|
-
// test suite start and finish
|
|
1134
|
-
// only relevant for workers
|
|
1135
|
-
addHook({
|
|
1136
|
-
name: '@vitest/runner',
|
|
1137
|
-
versions: ['>=1.6.0'],
|
|
1138
|
-
}, (vitestPackage, frameworkVersion) => {
|
|
1139
|
-
shimmer.wrap(vitestPackage, 'startTests', startTests => async function (testPaths) {
|
|
1140
|
-
let testSuiteError = null
|
|
1141
|
-
if (!testSuiteFinishCh.hasSubscribers) {
|
|
1142
|
-
return startTests.apply(this, arguments)
|
|
1143
|
-
}
|
|
1144
|
-
// From >=3.0.1, the first arguments changes from a string to an object containing the filepath
|
|
1145
|
-
const testSuiteAbsolutePath = testPaths[0]?.filepath || testPaths[0]
|
|
1146
|
-
|
|
1147
|
-
const testSuiteCtx = { testSuiteAbsolutePath, frameworkVersion }
|
|
1148
|
-
testSuiteStartCh.runStores(testSuiteCtx, () => {})
|
|
1149
|
-
const startTestsResponse = await startTests.apply(this, arguments)
|
|
1150
|
-
|
|
1151
|
-
let onFinish = null
|
|
1152
|
-
const onFinishPromise = new Promise(resolve => {
|
|
1153
|
-
onFinish = resolve
|
|
1154
|
-
})
|
|
1155
|
-
|
|
1156
|
-
const testTasks = getTypeTasks(startTestsResponse[0].tasks)
|
|
1157
|
-
|
|
1158
|
-
// Only one test task per test, even if there are retries
|
|
1159
|
-
for (const task of testTasks) {
|
|
1160
|
-
const testCtx = taskToCtx.get(task)
|
|
1161
|
-
const { result } = task
|
|
1162
|
-
// We have to trick vitest into thinking that the test has passed
|
|
1163
|
-
// but we want to report it as failed if it did fail
|
|
1164
|
-
const isSwitchedStatus = switchedStatuses.has(task)
|
|
1165
|
-
|
|
1166
|
-
if (result) {
|
|
1167
|
-
const { state, duration, errors } = result
|
|
1168
|
-
if (state === 'skip') { // programmatic skip
|
|
1169
|
-
testSkipCh.publish({
|
|
1170
|
-
testName: getTestName(task),
|
|
1171
|
-
testSuiteAbsolutePath: task.file.filepath,
|
|
1172
|
-
isNew: newTasks.has(task),
|
|
1173
|
-
isDisabled: disabledTasks.has(task),
|
|
1174
|
-
})
|
|
1175
|
-
} else if (state === 'pass' && !isSwitchedStatus) {
|
|
1176
|
-
if (testCtx) {
|
|
1177
|
-
testPassCh.publish({ task, ...testCtx.currentStore })
|
|
1178
|
-
}
|
|
1179
|
-
} else if (state === 'fail' || isSwitchedStatus) {
|
|
1180
|
-
let testError
|
|
1181
|
-
|
|
1182
|
-
if (errors?.length) {
|
|
1183
|
-
testError = errors[0]
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
let hasFailedAllRetries = false
|
|
1187
|
-
let attemptToFixFailed = false
|
|
1188
|
-
if (attemptToFixTasks.has(task)) {
|
|
1189
|
-
const statuses = taskToStatuses.get(task)
|
|
1190
|
-
if (statuses.includes('fail')) {
|
|
1191
|
-
attemptToFixFailed = true
|
|
1192
|
-
}
|
|
1193
|
-
if (statuses.every(status => status === 'fail')) {
|
|
1194
|
-
hasFailedAllRetries = true
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
// Check if all EFD retries failed
|
|
1199
|
-
const providedContext = getProvidedContext()
|
|
1200
|
-
if (providedContext.isEarlyFlakeDetectionEnabled && (newTasks.has(task) || modifiedTasks.has(task))) {
|
|
1201
|
-
const statuses = taskToStatuses.get(task)
|
|
1202
|
-
// statuses only includes repetitions (not the initial run), so we check against numRepeats (not +1)
|
|
1203
|
-
if (statuses && statuses.length === providedContext.numRepeats &&
|
|
1204
|
-
statuses.every(status => status === 'fail')) {
|
|
1205
|
-
hasFailedAllRetries = true
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
// ATR: set hasFailedAllRetries when all auto test retries were exhausted and every attempt failed
|
|
1210
|
-
if (providedContext.isFlakyTestRetriesEnabled && !attemptToFixTasks.has(task) &&
|
|
1211
|
-
!newTasks.has(task) && !modifiedTasks.has(task)) {
|
|
1212
|
-
const maxRetries = providedContext.flakyTestRetriesCount ?? 0
|
|
1213
|
-
if (maxRetries > 0 && task.result?.retryCount === maxRetries) {
|
|
1214
|
-
hasFailedAllRetries = true
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
if (testCtx) {
|
|
1219
|
-
const isRetry = task.result?.retryCount > 0
|
|
1220
|
-
// `duration` is the duration of all the retries, so it can't be used if there are retries
|
|
1221
|
-
testErrorCh.publish({
|
|
1222
|
-
duration: isRetry ? undefined : duration,
|
|
1223
|
-
error: testError,
|
|
1224
|
-
hasFailedAllRetries,
|
|
1225
|
-
attemptToFixFailed,
|
|
1226
|
-
...testCtx.currentStore,
|
|
1227
|
-
})
|
|
1228
|
-
}
|
|
1229
|
-
if (errors?.length) {
|
|
1230
|
-
testSuiteError = testError // we store the error to bubble it up to the suite
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
} else { // test.skip or test.todo
|
|
1234
|
-
testSkipCh.publish({
|
|
1235
|
-
testName: getTestName(task),
|
|
1236
|
-
testSuiteAbsolutePath: task.file.filepath,
|
|
1237
|
-
isNew: newTasks.has(task),
|
|
1238
|
-
isDisabled: disabledTasks.has(task),
|
|
1239
|
-
})
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
const testSuiteResult = startTestsResponse[0].result
|
|
1244
|
-
|
|
1245
|
-
if (testSuiteResult.errors?.length) { // Errors from root level hooks
|
|
1246
|
-
testSuiteError = testSuiteResult.errors[0]
|
|
1247
|
-
} else if (testSuiteResult.state === 'fail') { // Errors from `describe` level hooks
|
|
1248
|
-
const suiteTasks = getTypeTasks(startTestsResponse[0].tasks, 'suite')
|
|
1249
|
-
const failedSuites = suiteTasks.filter(task => task.result?.state === 'fail')
|
|
1250
|
-
if (failedSuites.length && failedSuites[0].result?.errors?.length) {
|
|
1251
|
-
testSuiteError = failedSuites[0].result.errors[0]
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
if (testSuiteError) {
|
|
1256
|
-
testSuiteCtx.error = testSuiteError
|
|
1257
|
-
testSuiteErrorCh.runStores(testSuiteCtx, () => {})
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
testSuiteFinishCh.publish({ status: testSuiteResult.state, onFinish, ...testSuiteCtx.currentStore })
|
|
1261
|
-
|
|
1262
|
-
await onFinishPromise
|
|
1263
|
-
|
|
1264
|
-
return startTestsResponse
|
|
1265
|
-
})
|
|
1266
|
-
|
|
1267
|
-
return vitestPackage
|
|
1268
|
-
})
|