@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
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
// Capture real timers at module load time, before any test can install fake timers.
|
|
4
4
|
const realSetTimeout = setTimeout
|
|
5
|
+
const realClearTimeout = clearTimeout
|
|
5
6
|
|
|
7
|
+
const { performance } = require('node:perf_hooks')
|
|
6
8
|
const satisfies = require('../../../vendor/dist/semifies')
|
|
7
9
|
|
|
8
10
|
const shimmer = require('../../datadog-shimmer')
|
|
@@ -12,20 +14,29 @@ const {
|
|
|
12
14
|
PLAYWRIGHT_WORKER_TRACE_PAYLOAD_CODE,
|
|
13
15
|
getIsFaultyEarlyFlakeDetection,
|
|
14
16
|
DYNAMIC_NAME_RE,
|
|
15
|
-
|
|
17
|
+
getEfdRetryCount,
|
|
18
|
+
getMaxEfdRetryCount,
|
|
19
|
+
recordAttemptToFixExecution,
|
|
20
|
+
logAttemptToFixTestExecution,
|
|
21
|
+
logTestOptimizationSummary,
|
|
22
|
+
getTestOptimizationRequestResults,
|
|
16
23
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
17
24
|
const log = require('../../dd-trace/src/log')
|
|
18
25
|
const {
|
|
19
26
|
getValueFromEnvSources,
|
|
20
27
|
} = require('../../dd-trace/src/config/helper')
|
|
28
|
+
const {
|
|
29
|
+
RUM_TEST_EXECUTION_ID_COOKIE_NAME: RUM_COOKIE_NAME,
|
|
30
|
+
} = require('../../dd-trace/src/ci-visibility/rum')
|
|
21
31
|
const { DD_MAJOR } = require('../../../version')
|
|
22
|
-
const { addHook, channel } = require('./helpers/instrument')
|
|
32
|
+
const { addHook, channel, tracingChannel } = require('./helpers/instrument')
|
|
23
33
|
|
|
24
34
|
const testStartCh = channel('ci:playwright:test:start')
|
|
25
35
|
const testFinishCh = channel('ci:playwright:test:finish')
|
|
26
36
|
const testSkipCh = channel('ci:playwright:test:skip')
|
|
27
37
|
|
|
28
38
|
const testSessionStartCh = channel('ci:playwright:session:start')
|
|
39
|
+
const testSessionConfigurationCh = channel('ci:playwright:session:configuration')
|
|
29
40
|
const testSessionFinishCh = channel('ci:playwright:session:finish')
|
|
30
41
|
|
|
31
42
|
const libraryConfigurationCh = channel('ci:playwright:library-configuration')
|
|
@@ -40,18 +51,33 @@ const testSuiteFinishCh = channel('ci:playwright:test-suite:finish')
|
|
|
40
51
|
const workerReportCh = channel('ci:playwright:worker:report')
|
|
41
52
|
const testPageGotoCh = channel('ci:playwright:test:page-goto')
|
|
42
53
|
|
|
54
|
+
const dispatcherRunCh = tracingChannel('orchestrion:playwright:Dispatcher_run')
|
|
55
|
+
const dispatcherCreateWorkerCh = tracingChannel('orchestrion:playwright:Dispatcher_createWorker')
|
|
56
|
+
const processHostStartRunnerCh = tracingChannel('orchestrion:playwright:ProcessHost_startRunner')
|
|
57
|
+
const createRootSuiteCh = tracingChannel('orchestrion:playwright:createRootSuite')
|
|
58
|
+
const artifactsRecorderScreenshotPathCh =
|
|
59
|
+
tracingChannel('orchestrion:playwright:ArtifactsRecorder_createScreenshotAttachmentPath')
|
|
60
|
+
const snapshotRecorderScreenshotPathCh = tracingChannel('orchestrion:playwright:SnapshotRecorder_createAttachmentPath')
|
|
61
|
+
const pageGotoCh = tracingChannel('orchestrion:playwright-core:Page_goto')
|
|
62
|
+
|
|
43
63
|
const testToCtx = new WeakMap()
|
|
44
64
|
const testSuiteToCtx = new Map()
|
|
45
65
|
const testSuiteToTestStatuses = new Map()
|
|
46
66
|
const testSuiteToErrors = new Map()
|
|
47
67
|
const testsToTestStatuses = new Map()
|
|
48
68
|
|
|
49
|
-
const RUM_FLUSH_WAIT_TIME =
|
|
69
|
+
const RUM_FLUSH_WAIT_TIME = getValueFromEnvSources('DD_CIVISIBILITY_RUM_FLUSH_WAIT_MILLIS')
|
|
70
|
+
const DD_PROPERTIES_TIMEOUT = 5000
|
|
71
|
+
const isFailureScreenshotUploadEnabled =
|
|
72
|
+
getValueFromEnvSources('DD_TEST_FAILURE_SCREENSHOTS_ENABLED') === true
|
|
50
73
|
|
|
51
74
|
let applyRepeatEachIndex = null
|
|
52
75
|
|
|
53
76
|
let startedSuites = []
|
|
54
77
|
|
|
78
|
+
// Browser-side callbacks live in a coverage-excluded file so coverage counters can't reach chromium.
|
|
79
|
+
const { detectRum, stopRumSession } = require('./playwright-browser-scripts')
|
|
80
|
+
|
|
55
81
|
const STATUS_TO_TEST_STATUS = {
|
|
56
82
|
passed: 'pass',
|
|
57
83
|
failed: 'fail',
|
|
@@ -63,6 +89,7 @@ let remainingTestsByFile = {}
|
|
|
63
89
|
let isKnownTestsEnabled = false
|
|
64
90
|
let isEarlyFlakeDetectionEnabled = false
|
|
65
91
|
let earlyFlakeDetectionNumRetries = 0
|
|
92
|
+
let earlyFlakeDetectionSlowTestRetries = {}
|
|
66
93
|
let isEarlyFlakeDetectionFaulty = false
|
|
67
94
|
let earlyFlakeDetectionFaultyThreshold = 0
|
|
68
95
|
let isFlakyTestRetriesEnabled = false
|
|
@@ -73,13 +100,45 @@ let testManagementAttemptToFixRetries = 0
|
|
|
73
100
|
let testManagementTests = {}
|
|
74
101
|
let isImpactedTestsEnabled = false
|
|
75
102
|
let modifiedFiles = {}
|
|
76
|
-
const quarantinedOrDisabledTestsAttemptToFix = []
|
|
77
103
|
let quarantinedButNotAttemptToFixFqns = new Set()
|
|
104
|
+
let testsReportedInGenerateSummary = new Set()
|
|
78
105
|
const newTestsWithDynamicNames = new Set()
|
|
106
|
+
const attemptToFixExecutions = new Map()
|
|
107
|
+
const loggedAttemptToFixTests = new Set()
|
|
108
|
+
const efdManagedTestKeys = new Set()
|
|
109
|
+
const efdRetryCountByTestKey = new Map()
|
|
110
|
+
const efdRetryCountRequestsByTestKey = new Map()
|
|
111
|
+
const efdRetryTestsById = new Map()
|
|
112
|
+
const efdScheduledOriginalTestKeys = new Set()
|
|
113
|
+
const efdStartedOriginalTestKeys = new Set()
|
|
114
|
+
const efdSlowAbortedTests = new Set()
|
|
115
|
+
const ddPropertiesByTestId = new Map()
|
|
116
|
+
const ddPropertiesRequestsByTestId = new Map()
|
|
117
|
+
const disabledTestIds = new Set()
|
|
79
118
|
let rootDir = ''
|
|
80
119
|
let sessionProjects = []
|
|
81
120
|
|
|
82
121
|
const MINIMUM_SUPPORTED_VERSION_RANGE_EFD = '>=1.38.0' // TODO: remove this once we drop support for v5
|
|
122
|
+
const EFD_RETRY_COUNT_REQUEST = 'ddEfdRetryCountRequest'
|
|
123
|
+
const EFD_RETRY_COUNT_RESPONSE = 'ddEfdRetryCountResponse'
|
|
124
|
+
const DD_PROPERTIES_REQUEST = 'ddPropertiesRequest'
|
|
125
|
+
const DD_PROPERTIES_RESPONSE = 'ddProperties'
|
|
126
|
+
const kDdPlaywrightDisabledTestIds = Symbol('ddPlaywrightDisabledTestIds')
|
|
127
|
+
const kDdPlaywrightFailureScreenshots = Symbol('ddPlaywrightFailureScreenshots')
|
|
128
|
+
const kDdPlaywrightWorkerHostInstrumented = Symbol('ddPlaywrightWorkerHostInstrumented')
|
|
129
|
+
const kDdPlaywrightWorkerInstrumented = Symbol('ddPlaywrightWorkerInstrumented')
|
|
130
|
+
const PLAYWRIGHT_FAILURE_SCREENSHOT_PATH_RE = /(?:^|[\\/])test-failed-\d+\.png$/
|
|
131
|
+
const automaticFailureScreenshotPaths = new Set()
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Returns whether Playwright's internal screenshot recorder created an attachment.
|
|
135
|
+
*
|
|
136
|
+
* @param {object} attachment - Playwright attachment payload
|
|
137
|
+
* @returns {boolean}
|
|
138
|
+
*/
|
|
139
|
+
function isAutomaticFailureScreenshotAttachment (attachment) {
|
|
140
|
+
return typeof attachment?.path === 'string' && automaticFailureScreenshotPaths.delete(attachment.path)
|
|
141
|
+
}
|
|
83
142
|
|
|
84
143
|
function isValidKnownTests (receivedKnownTests) {
|
|
85
144
|
return !!receivedKnownTests.playwright
|
|
@@ -90,6 +149,259 @@ function getTestFullyQualifiedName (test) {
|
|
|
90
149
|
return `${test._requireFile} ${fullname}`
|
|
91
150
|
}
|
|
92
151
|
|
|
152
|
+
/**
|
|
153
|
+
* @param {object} test
|
|
154
|
+
* @returns {string|undefined}
|
|
155
|
+
*/
|
|
156
|
+
function getTestProjectKey (test) {
|
|
157
|
+
const { _projectIndex, _projectId } = test
|
|
158
|
+
if (_projectIndex !== undefined) {
|
|
159
|
+
return `index:${_projectIndex}`
|
|
160
|
+
}
|
|
161
|
+
if (_projectId !== undefined) {
|
|
162
|
+
return `id:${_projectId}`
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const projectSuite = getSuiteType(test, 'project')
|
|
166
|
+
const projectName = projectSuite?._fullProject?.project?.name ||
|
|
167
|
+
projectSuite?._fullProject?.name ||
|
|
168
|
+
projectSuite?.title
|
|
169
|
+
if (projectName) {
|
|
170
|
+
return `name:${projectName}`
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @param {object} test
|
|
176
|
+
* @returns {number|undefined}
|
|
177
|
+
*/
|
|
178
|
+
function getTestEfdRepeatEachIndex (test) {
|
|
179
|
+
if (Object.hasOwn(test, '_ddEfdOriginalRepeatEachIndex')) {
|
|
180
|
+
return test._ddEfdOriginalRepeatEachIndex
|
|
181
|
+
}
|
|
182
|
+
return test.repeatEachIndex
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @param {object} test
|
|
187
|
+
* @returns {string|undefined}
|
|
188
|
+
*/
|
|
189
|
+
function getTestRepeatEachKey (test) {
|
|
190
|
+
const repeatEachIndex = getTestEfdRepeatEachIndex(test)
|
|
191
|
+
if (repeatEachIndex !== undefined) {
|
|
192
|
+
return `repeat:${repeatEachIndex}`
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @param {object} test
|
|
198
|
+
* @returns {string}
|
|
199
|
+
*/
|
|
200
|
+
function getTestEfdKey (test) {
|
|
201
|
+
const projectKey = getTestProjectKey(test)
|
|
202
|
+
const repeatEachKey = getTestRepeatEachKey(test)
|
|
203
|
+
const testFqn = getTestFullyQualifiedName(test)
|
|
204
|
+
return [projectKey, repeatEachKey, testFqn].filter(Boolean).join(' ')
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function getConfiguredEfdRetryCount () {
|
|
208
|
+
if (!earlyFlakeDetectionSlowTestRetries || !Object.keys(earlyFlakeDetectionSlowTestRetries).length) {
|
|
209
|
+
return earlyFlakeDetectionNumRetries
|
|
210
|
+
}
|
|
211
|
+
return getMaxEfdRetryCount(earlyFlakeDetectionSlowTestRetries)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function markEfdManagedTest (test) {
|
|
215
|
+
test._ddIsEfdManagedTest = true
|
|
216
|
+
test._ddEfdSlowTestRetries = earlyFlakeDetectionSlowTestRetries
|
|
217
|
+
efdManagedTestKeys.add(getTestEfdKey(test))
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function markEfdRetryTest (test, retryIndex, originalTest) {
|
|
221
|
+
test._ddIsEfdRetry = true
|
|
222
|
+
test._ddEfdRetryIndex = retryIndex
|
|
223
|
+
if (originalTest) {
|
|
224
|
+
test._ddEfdOriginalRepeatEachIndex = getTestEfdRepeatEachIndex(originalTest)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function registerEfdRetryTest (test) {
|
|
229
|
+
if (!test._ddIsEfdRetry) {
|
|
230
|
+
return
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
efdRetryTestsById.set(test.id, {
|
|
234
|
+
retryIndex: test._ddEfdRetryIndex,
|
|
235
|
+
testEfdKey: getTestEfdKey(test),
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function getTestEfdSlowTestRetries (test) {
|
|
240
|
+
return test._ddEfdSlowTestRetries || earlyFlakeDetectionSlowTestRetries
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function isTestEfdManaged (test) {
|
|
244
|
+
return !!test._ddIsEfdManagedTest || (
|
|
245
|
+
(test._ddIsNew || test._ddIsModified) &&
|
|
246
|
+
!test._ddIsAttemptToFix &&
|
|
247
|
+
isEarlyFlakeDetectionEnabled
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function getFileSuiteRepeatEachIndex (fileSuite) {
|
|
252
|
+
const test = fileSuite.allTests()[0]
|
|
253
|
+
return test ? getTestEfdRepeatEachIndex(test) || 0 : 0
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function getEfdRetryRepeatEachIndex (fileSuite, projectSuite, retryIndex, retryCount) {
|
|
257
|
+
const nativeRepeatEach = projectSuite._fullProject?.project?.repeatEach || 1
|
|
258
|
+
const originalRepeatEachIndex = getFileSuiteRepeatEachIndex(fileSuite)
|
|
259
|
+
return nativeRepeatEach + (originalRepeatEachIndex * retryCount) + retryIndex - 1
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function getEfdRetryCountForTest (test) {
|
|
263
|
+
return efdRetryCountByTestKey.get(getTestEfdKey(test)) ?? getConfiguredEfdRetryCount()
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function setEfdRetryCountForTest (test, retryCount) {
|
|
267
|
+
const testEfdKey = getTestEfdKey(test)
|
|
268
|
+
efdRetryCountByTestKey.set(testEfdKey, retryCount)
|
|
269
|
+
|
|
270
|
+
const requests = efdRetryCountRequestsByTestKey.get(testEfdKey)
|
|
271
|
+
if (requests) {
|
|
272
|
+
efdRetryCountRequestsByTestKey.delete(testEfdKey)
|
|
273
|
+
for (const resolveRequest of requests) {
|
|
274
|
+
resolveRequest(retryCount)
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function sendEfdRetryCountToWorker (workerProcess, testId, retryIndex, retryCount) {
|
|
280
|
+
workerProcess.send({
|
|
281
|
+
type: EFD_RETRY_COUNT_RESPONSE,
|
|
282
|
+
testId,
|
|
283
|
+
isEfdRetry: retryIndex !== undefined,
|
|
284
|
+
retryIndex,
|
|
285
|
+
retryCount,
|
|
286
|
+
})
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function sendEfdRetryCountToWorkerWhenAvailable (workerProcess, testId) {
|
|
290
|
+
const efdRetryTest = efdRetryTestsById.get(testId)
|
|
291
|
+
if (!efdRetryTest) {
|
|
292
|
+
sendEfdRetryCountToWorker(workerProcess, testId)
|
|
293
|
+
return
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const { retryIndex, testEfdKey } = efdRetryTest
|
|
297
|
+
|
|
298
|
+
if (!testEfdKey || !efdManagedTestKeys.has(testEfdKey)) {
|
|
299
|
+
sendEfdRetryCountToWorker(workerProcess, testId)
|
|
300
|
+
return
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const retryCount = efdRetryCountByTestKey.get(testEfdKey)
|
|
304
|
+
if (retryCount !== undefined) {
|
|
305
|
+
sendEfdRetryCountToWorker(workerProcess, testId, retryIndex, retryCount)
|
|
306
|
+
return
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (!efdStartedOriginalTestKeys.has(testEfdKey) && !efdScheduledOriginalTestKeys.has(testEfdKey)) {
|
|
310
|
+
sendEfdRetryCountToWorker(workerProcess, testId, retryIndex, 0)
|
|
311
|
+
return
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (!efdRetryCountRequestsByTestKey.has(testEfdKey)) {
|
|
315
|
+
efdRetryCountRequestsByTestKey.set(testEfdKey, [])
|
|
316
|
+
}
|
|
317
|
+
efdRetryCountRequestsByTestKey.get(testEfdKey).push((retryCount) => {
|
|
318
|
+
sendEfdRetryCountToWorker(workerProcess, testId, retryIndex, retryCount)
|
|
319
|
+
})
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function sendDdPropertiesToWorker (workerProcess, testId, properties) {
|
|
323
|
+
workerProcess.send({
|
|
324
|
+
type: DD_PROPERTIES_RESPONSE,
|
|
325
|
+
testId,
|
|
326
|
+
properties,
|
|
327
|
+
})
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function setDdPropertiesForTest (workerProcess, testId, properties) {
|
|
331
|
+
ddPropertiesByTestId.set(testId, properties)
|
|
332
|
+
|
|
333
|
+
const requests = ddPropertiesRequestsByTestId.get(testId)
|
|
334
|
+
if (requests) {
|
|
335
|
+
ddPropertiesRequestsByTestId.delete(testId)
|
|
336
|
+
for (const resolveRequest of requests) {
|
|
337
|
+
resolveRequest(properties)
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
sendDdPropertiesToWorker(workerProcess, testId, properties)
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function sendDdPropertiesToWorkerWhenAvailable (workerProcess, testId) {
|
|
345
|
+
const properties = ddPropertiesByTestId.get(testId)
|
|
346
|
+
if (properties) {
|
|
347
|
+
sendDdPropertiesToWorker(workerProcess, testId, properties)
|
|
348
|
+
return
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (!ddPropertiesRequestsByTestId.has(testId)) {
|
|
352
|
+
ddPropertiesRequestsByTestId.set(testId, [])
|
|
353
|
+
}
|
|
354
|
+
ddPropertiesRequestsByTestId.get(testId).push((properties) => {
|
|
355
|
+
sendDdPropertiesToWorker(workerProcess, testId, properties)
|
|
356
|
+
})
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* @param {object} test
|
|
361
|
+
* @returns {boolean}
|
|
362
|
+
*/
|
|
363
|
+
function shouldRequestEfdRetryCount (test) {
|
|
364
|
+
// The main process remains the source of truth. repeatEachIndex is only used as
|
|
365
|
+
// a cheap worker-side filter so first executions do not block on coordination.
|
|
366
|
+
return test._ddIsEfdRetry || test.repeatEachIndex > 0
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function waitForEfdRetryCount (test) {
|
|
370
|
+
if (!process.send || !shouldRequestEfdRetryCount(test)) {
|
|
371
|
+
return Promise.resolve()
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const testEfdKey = getTestEfdKey(test)
|
|
375
|
+
return new Promise(resolve => {
|
|
376
|
+
const messageHandler = (message) => {
|
|
377
|
+
if (message?.type === EFD_RETRY_COUNT_RESPONSE && message.testId === test.id) {
|
|
378
|
+
if (message.isEfdRetry) {
|
|
379
|
+
test._ddIsEfdRetry = true
|
|
380
|
+
test._ddEfdRetryIndex = message.retryIndex
|
|
381
|
+
test._ddEfdRetryCount = message.retryCount
|
|
382
|
+
efdRetryCountByTestKey.set(testEfdKey, message.retryCount)
|
|
383
|
+
}
|
|
384
|
+
process.removeListener('message', messageHandler)
|
|
385
|
+
resolve()
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
process.on('message', messageHandler)
|
|
390
|
+
process.send({
|
|
391
|
+
type: EFD_RETRY_COUNT_REQUEST,
|
|
392
|
+
testId: test.id,
|
|
393
|
+
})
|
|
394
|
+
})
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function shouldSkipEfdRetry (test) {
|
|
398
|
+
if (!test._ddIsEfdRetry) {
|
|
399
|
+
return false
|
|
400
|
+
}
|
|
401
|
+
const retryCount = test._ddEfdRetryCount ?? efdRetryCountByTestKey.get(getTestEfdKey(test))
|
|
402
|
+
return retryCount !== undefined && test._ddEfdRetryIndex > retryCount
|
|
403
|
+
}
|
|
404
|
+
|
|
93
405
|
function getTestProperties (test) {
|
|
94
406
|
const testName = getTestFullname(test)
|
|
95
407
|
const testSuite = getTestSuitePath(test._requireFile, rootDir)
|
|
@@ -117,15 +429,22 @@ function getSuiteType (test, type) {
|
|
|
117
429
|
return suite
|
|
118
430
|
}
|
|
119
431
|
|
|
432
|
+
function isSuiteEntry (entry) {
|
|
433
|
+
return entry.constructor.name === 'Suite' || entry.constructor.name === '_Suite'
|
|
434
|
+
}
|
|
435
|
+
|
|
120
436
|
// Copy of Suite#_deepClone but with a function to filter tests
|
|
121
|
-
function deepCloneSuite (suite, filterTest, tags = []) {
|
|
437
|
+
function deepCloneSuite (suite, filterTest, tags = [], configureCopiedTest) {
|
|
122
438
|
const copy = suite._clone()
|
|
123
439
|
for (const entry of suite._entries) {
|
|
124
|
-
if (entry
|
|
125
|
-
copy._addSuite(deepCloneSuite(entry, filterTest, tags))
|
|
440
|
+
if (isSuiteEntry(entry)) {
|
|
441
|
+
copy._addSuite(deepCloneSuite(entry, filterTest, tags, configureCopiedTest))
|
|
126
442
|
} else {
|
|
127
443
|
if (filterTest(entry)) {
|
|
128
444
|
const copiedTest = entry._clone()
|
|
445
|
+
if (configureCopiedTest) {
|
|
446
|
+
configureCopiedTest(copiedTest, entry)
|
|
447
|
+
}
|
|
129
448
|
for (const tag of tags) {
|
|
130
449
|
const resolvedTag = typeof tag === 'function' ? tag(entry) : tag
|
|
131
450
|
|
|
@@ -204,7 +523,28 @@ function getProjectsFromRunner (runner, configArg) {
|
|
|
204
523
|
})
|
|
205
524
|
}
|
|
206
525
|
|
|
526
|
+
/**
|
|
527
|
+
* Returns whether at least one Playwright project captures automatic screenshots for failed tests.
|
|
528
|
+
*
|
|
529
|
+
* @param {Array<object>} projects - Playwright projects with resolved use options
|
|
530
|
+
* @returns {boolean} Whether failure screenshot capture is enabled
|
|
531
|
+
*/
|
|
532
|
+
function isFailureScreenshotCaptureEnabled (projects) {
|
|
533
|
+
for (const project of projects) {
|
|
534
|
+
const screenshot = project.use?.screenshot
|
|
535
|
+
const mode = typeof screenshot === 'object' && screenshot !== null ? screenshot.mode : screenshot
|
|
536
|
+
if (mode === 'on' || mode === 'only-on-failure' || mode === 'on-first-failure') {
|
|
537
|
+
return true
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return false
|
|
541
|
+
}
|
|
542
|
+
|
|
207
543
|
function getProjectsFromDispatcher (dispatcher) {
|
|
544
|
+
const bundledConfig = dispatcher._testRun?.config?.config?.projects
|
|
545
|
+
if (bundledConfig) {
|
|
546
|
+
return bundledConfig
|
|
547
|
+
}
|
|
208
548
|
const newConfig = dispatcher._config?.config?.projects
|
|
209
549
|
if (newConfig) {
|
|
210
550
|
return newConfig
|
|
@@ -287,6 +627,36 @@ function testWillRetry (test, testStatus) {
|
|
|
287
627
|
return testStatus === 'fail' && test.results.length <= test.retries
|
|
288
628
|
}
|
|
289
629
|
|
|
630
|
+
function getFinalStatus ({
|
|
631
|
+
isFinalExecution,
|
|
632
|
+
isDisabled,
|
|
633
|
+
isQuarantined,
|
|
634
|
+
isAtrRetry,
|
|
635
|
+
isEfdManagedTest,
|
|
636
|
+
isAttemptToFix,
|
|
637
|
+
hasFailedAllRetries,
|
|
638
|
+
hasFailedAttemptToFixRetries,
|
|
639
|
+
hasPassedAnyEfdAttempt,
|
|
640
|
+
testStatus,
|
|
641
|
+
}) {
|
|
642
|
+
if (!isFinalExecution) {
|
|
643
|
+
return
|
|
644
|
+
}
|
|
645
|
+
if (isDisabled || isQuarantined || testStatus === 'skip') {
|
|
646
|
+
return 'skip'
|
|
647
|
+
}
|
|
648
|
+
if (isAtrRetry) {
|
|
649
|
+
return hasFailedAllRetries ? 'fail' : 'pass'
|
|
650
|
+
}
|
|
651
|
+
if (isEfdManagedTest) {
|
|
652
|
+
return hasPassedAnyEfdAttempt ? 'pass' : 'fail'
|
|
653
|
+
}
|
|
654
|
+
if (isAttemptToFix) {
|
|
655
|
+
return hasFailedAttemptToFixRetries ? 'fail' : 'pass'
|
|
656
|
+
}
|
|
657
|
+
return testStatus
|
|
658
|
+
}
|
|
659
|
+
|
|
290
660
|
function getTestFullname (test) {
|
|
291
661
|
let parent = test.parent
|
|
292
662
|
const names = [test.title]
|
|
@@ -317,6 +687,14 @@ function testBeginHandler (test, browserName, shouldCreateTestSpan) {
|
|
|
317
687
|
if (_type === 'beforeAll' || _type === 'afterAll') {
|
|
318
688
|
return
|
|
319
689
|
}
|
|
690
|
+
if (shouldSkipEfdRetry(test)) {
|
|
691
|
+
test._ddShouldSkipEfdRetry = true
|
|
692
|
+
return
|
|
693
|
+
}
|
|
694
|
+
test._ddStartTime = performance.now()
|
|
695
|
+
if (isTestEfdManaged(test) && !test._ddIsEfdRetry) {
|
|
696
|
+
efdStartedOriginalTestKeys.add(getTestEfdKey(test))
|
|
697
|
+
}
|
|
320
698
|
// this means that a skipped test is being handled
|
|
321
699
|
if (!remainingTestsByFile[testSuiteAbsolutePath].length) {
|
|
322
700
|
return
|
|
@@ -334,6 +712,11 @@ function testBeginHandler (test, browserName, shouldCreateTestSpan) {
|
|
|
334
712
|
// We disable retries by default if attemptToFix is true
|
|
335
713
|
if (getTestProperties(test).attemptToFix) {
|
|
336
714
|
test.retries = 0
|
|
715
|
+
logAttemptToFixTestExecution(
|
|
716
|
+
getTestSuitePath(testSuiteAbsolutePath, rootDir),
|
|
717
|
+
getTestFullname(test),
|
|
718
|
+
loggedAttemptToFixTests
|
|
719
|
+
)
|
|
337
720
|
}
|
|
338
721
|
|
|
339
722
|
// this handles tests that do not go through the worker process (because they're skipped)
|
|
@@ -353,6 +736,45 @@ function testBeginHandler (test, browserName, shouldCreateTestSpan) {
|
|
|
353
736
|
}
|
|
354
737
|
}
|
|
355
738
|
|
|
739
|
+
function finishTestSuiteIfDone (testSuiteAbsolutePath, projects) {
|
|
740
|
+
if (!shouldFinishTestSuite(testSuiteAbsolutePath)) {
|
|
741
|
+
return
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
const skippedTests = remainingTestsByFile[testSuiteAbsolutePath]
|
|
745
|
+
.filter(test => test.expectedStatus === 'skipped')
|
|
746
|
+
|
|
747
|
+
for (const test of skippedTests) {
|
|
748
|
+
const browserName = getBrowserNameFromProjects(projects, test)
|
|
749
|
+
testSkipCh.publish({
|
|
750
|
+
testName: getTestFullname(test),
|
|
751
|
+
testSuiteAbsolutePath,
|
|
752
|
+
testSourceFileAbsolutePath: test.location.file,
|
|
753
|
+
testSourceLine: test.location.line,
|
|
754
|
+
browserName,
|
|
755
|
+
isNew: test._ddIsNew,
|
|
756
|
+
isDisabled: test._ddIsDisabled,
|
|
757
|
+
isModified: test._ddIsModified,
|
|
758
|
+
isQuarantined: test._ddIsQuarantined,
|
|
759
|
+
})
|
|
760
|
+
}
|
|
761
|
+
remainingTestsByFile[testSuiteAbsolutePath] = []
|
|
762
|
+
|
|
763
|
+
const testStatuses = testSuiteToTestStatuses.get(testSuiteAbsolutePath)
|
|
764
|
+
let testSuiteStatus = 'pass'
|
|
765
|
+
if (testStatuses?.includes('fail')) {
|
|
766
|
+
testSuiteStatus = 'fail'
|
|
767
|
+
} else if (testStatuses?.every(status => status === 'skip')) {
|
|
768
|
+
testSuiteStatus = 'skip'
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
const suiteError = getTestSuiteError(testSuiteAbsolutePath)
|
|
772
|
+
const testSuiteCtx = testSuiteToCtx.get(testSuiteAbsolutePath)
|
|
773
|
+
if (testSuiteCtx) {
|
|
774
|
+
testSuiteFinishCh.publish({ status: testSuiteStatus, error: suiteError, ...testSuiteCtx.currentStore })
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
356
778
|
function testEndHandler ({
|
|
357
779
|
test,
|
|
358
780
|
annotations,
|
|
@@ -382,11 +804,21 @@ function testEndHandler ({
|
|
|
382
804
|
return
|
|
383
805
|
}
|
|
384
806
|
|
|
807
|
+
if (test._ddShouldSkipEfdRetry || shouldSkipEfdRetry(test)) {
|
|
808
|
+
test._ddShouldSkipEfdRetry = true
|
|
809
|
+
remainingTestsByFile[testSuiteAbsolutePath] = remainingTestsByFile[testSuiteAbsolutePath]
|
|
810
|
+
.filter(currentTest => currentTest !== test)
|
|
811
|
+
finishTestSuiteIfDone(testSuiteAbsolutePath, projects)
|
|
812
|
+
return
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
const isEfdManagedTest = isTestEfdManaged(test)
|
|
385
816
|
const testFqn = getTestFullyQualifiedName(test)
|
|
386
|
-
const
|
|
817
|
+
const testStatusKey = isEfdManagedTest ? getTestEfdKey(test) : testFqn
|
|
818
|
+
const testStatuses = testsToTestStatuses.get(testStatusKey) || []
|
|
387
819
|
|
|
388
820
|
if (testStatuses.length === 0) {
|
|
389
|
-
testsToTestStatuses.set(
|
|
821
|
+
testsToTestStatuses.set(testStatusKey, [testStatus])
|
|
390
822
|
if (test._ddIsNew && DYNAMIC_NAME_RE.test(getTestFullname(test))) {
|
|
391
823
|
newTestsWithDynamicNames.add(`${getTestSuitePath(test._requireFile, rootDir)} › ${getTestFullname(test)}`)
|
|
392
824
|
}
|
|
@@ -394,8 +826,33 @@ function testEndHandler ({
|
|
|
394
826
|
testStatuses.push(testStatus)
|
|
395
827
|
}
|
|
396
828
|
|
|
829
|
+
const testEfdKey = getTestEfdKey(test)
|
|
830
|
+
if (isEfdManagedTest && !test._ddIsEfdRetry && !efdRetryCountByTestKey.has(testEfdKey)) {
|
|
831
|
+
const testResult = results.at(-1)
|
|
832
|
+
const duration = testResult?.duration > 0 ? testResult.duration : performance.now() - test._ddStartTime
|
|
833
|
+
const retryCount = getEfdRetryCount(duration, getTestEfdSlowTestRetries(test))
|
|
834
|
+
setEfdRetryCountForTest(test, retryCount)
|
|
835
|
+
if (retryCount === 0) {
|
|
836
|
+
efdSlowAbortedTests.add(testEfdKey)
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
|
|
397
840
|
const testProperties = getTestProperties(test)
|
|
398
841
|
|
|
842
|
+
if (testProperties.attemptToFix) {
|
|
843
|
+
test._ddHasFailedAttemptToFixRetries = false
|
|
844
|
+
test._ddHasFailedAllRetries = false
|
|
845
|
+
test._ddHasPassedAttemptToFixRetries = false
|
|
846
|
+
|
|
847
|
+
recordAttemptToFixExecution(attemptToFixExecutions, {
|
|
848
|
+
testSuite: getTestSuitePath(test._requireFile, rootDir),
|
|
849
|
+
testName: getTestFullname(test),
|
|
850
|
+
status: testStatus,
|
|
851
|
+
isDisabled: testProperties.disabled,
|
|
852
|
+
isQuarantined: testProperties.quarantined,
|
|
853
|
+
})
|
|
854
|
+
}
|
|
855
|
+
|
|
399
856
|
if (testStatuses.length === testManagementAttemptToFixRetries + 1 && testProperties.attemptToFix) {
|
|
400
857
|
if (testStatuses.includes('fail')) {
|
|
401
858
|
test._ddHasFailedAttemptToFixRetries = true
|
|
@@ -408,9 +865,10 @@ function testEndHandler ({
|
|
|
408
865
|
}
|
|
409
866
|
|
|
410
867
|
// Check if all EFD retries failed
|
|
411
|
-
|
|
868
|
+
const efdRetryCount = getEfdRetryCountForTest(test)
|
|
869
|
+
if (efdRetryCount > 0 && testStatuses.length === efdRetryCount + 1 &&
|
|
412
870
|
(test._ddIsNew || test._ddIsModified) &&
|
|
413
|
-
|
|
871
|
+
isEarlyFlakeDetectionEnabled &&
|
|
414
872
|
testStatuses.every(status => status === 'fail')) {
|
|
415
873
|
test._ddHasFailedAllRetries = true
|
|
416
874
|
}
|
|
@@ -424,6 +882,8 @@ function testEndHandler ({
|
|
|
424
882
|
test._ddHasFailedAllRetries = true
|
|
425
883
|
}
|
|
426
884
|
|
|
885
|
+
const willRetry = testWillRetry(test, testStatus)
|
|
886
|
+
|
|
427
887
|
// this handles tests that do not go through the worker process (because they're skipped)
|
|
428
888
|
if (shouldCreateTestSpan) {
|
|
429
889
|
const testResult = results.at(-1)
|
|
@@ -432,6 +892,20 @@ function testEndHandler ({
|
|
|
432
892
|
isFlakyTestRetriesEnabled &&
|
|
433
893
|
!test._ddIsAttemptToFix &&
|
|
434
894
|
!test._ddIsEfdRetry
|
|
895
|
+
|
|
896
|
+
const finalStatus = getFinalStatus({
|
|
897
|
+
isFinalExecution: !willRetry,
|
|
898
|
+
isDisabled: test._ddIsDisabled,
|
|
899
|
+
isQuarantined: test._ddIsQuarantined,
|
|
900
|
+
isAtrRetry,
|
|
901
|
+
isEfdManagedTest,
|
|
902
|
+
isAttemptToFix: test._ddIsAttemptToFix,
|
|
903
|
+
hasFailedAllRetries: test._ddHasFailedAllRetries,
|
|
904
|
+
hasFailedAttemptToFixRetries: test._ddHasFailedAttemptToFixRetries,
|
|
905
|
+
hasPassedAnyEfdAttempt: testStatuses.includes('pass'),
|
|
906
|
+
testStatus,
|
|
907
|
+
})
|
|
908
|
+
|
|
435
909
|
// if there is no testCtx, the skipped test will be created later
|
|
436
910
|
if (testCtx) {
|
|
437
911
|
testFinishCh.publish({
|
|
@@ -451,94 +925,239 @@ function testEndHandler ({
|
|
|
451
925
|
hasFailedAttemptToFixRetries: test._ddHasFailedAttemptToFixRetries,
|
|
452
926
|
isAtrRetry,
|
|
453
927
|
isModified: test._ddIsModified,
|
|
928
|
+
finalStatus,
|
|
929
|
+
earlyFlakeAbortReason: efdSlowAbortedTests.has(testEfdKey) ? 'slow' : undefined,
|
|
454
930
|
...testCtx.currentStore,
|
|
455
931
|
})
|
|
456
932
|
}
|
|
457
933
|
}
|
|
458
934
|
|
|
459
|
-
if (
|
|
460
|
-
testSuiteToTestStatuses.
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
935
|
+
if (!willRetry) {
|
|
936
|
+
if (testSuiteToTestStatuses.has(testSuiteAbsolutePath)) {
|
|
937
|
+
testSuiteToTestStatuses.get(testSuiteAbsolutePath).push(testStatus)
|
|
938
|
+
} else {
|
|
939
|
+
testSuiteToTestStatuses.set(testSuiteAbsolutePath, [testStatus])
|
|
940
|
+
}
|
|
464
941
|
|
|
465
|
-
|
|
466
|
-
|
|
942
|
+
if (error) {
|
|
943
|
+
addErrorToTestSuite(testSuiteAbsolutePath, error)
|
|
944
|
+
}
|
|
467
945
|
}
|
|
468
946
|
|
|
469
|
-
if (!
|
|
947
|
+
if (!willRetry) {
|
|
470
948
|
remainingTestsByFile[testSuiteAbsolutePath] = remainingTestsByFile[testSuiteAbsolutePath]
|
|
471
949
|
.filter(currentTest => currentTest !== test)
|
|
472
950
|
}
|
|
473
951
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
.filter(test => test.expectedStatus === 'skipped')
|
|
952
|
+
finishTestSuiteIfDone(testSuiteAbsolutePath, projects)
|
|
953
|
+
}
|
|
477
954
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
955
|
+
function dispatcherRunWrapper (run) {
|
|
956
|
+
return function (...args) {
|
|
957
|
+
remainingTestsByFile = getTestsBySuiteFromTestsById(this._testById)
|
|
958
|
+
return run.apply(this, args)
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
function deferEfdRetryGroups (testGroups) {
|
|
963
|
+
const groupsWithOriginalTests = []
|
|
964
|
+
const efdRetryOnlyGroups = []
|
|
965
|
+
|
|
966
|
+
for (const group of testGroups) {
|
|
967
|
+
const originalTests = []
|
|
968
|
+
const efdRetryTests = []
|
|
969
|
+
|
|
970
|
+
for (const test of group.tests) {
|
|
971
|
+
if (test._ddIsEfdRetry) {
|
|
972
|
+
efdRetryTests.push(test)
|
|
973
|
+
} else {
|
|
974
|
+
originalTests.push(test)
|
|
975
|
+
if (isTestEfdManaged(test)) {
|
|
976
|
+
efdScheduledOriginalTestKeys.add(getTestEfdKey(test))
|
|
977
|
+
}
|
|
978
|
+
}
|
|
491
979
|
}
|
|
492
|
-
remainingTestsByFile[testSuiteAbsolutePath] = []
|
|
493
980
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
if (testStatuses.includes('fail')) {
|
|
497
|
-
testSuiteStatus = 'fail'
|
|
498
|
-
} else if (testStatuses.every(status => status === 'skip')) {
|
|
499
|
-
testSuiteStatus = 'skip'
|
|
981
|
+
if (efdRetryTests.length && originalTests.length) {
|
|
982
|
+
group.tests = [...originalTests, ...efdRetryTests]
|
|
500
983
|
}
|
|
501
984
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
985
|
+
if (originalTests.length) {
|
|
986
|
+
groupsWithOriginalTests.push(group)
|
|
987
|
+
} else {
|
|
988
|
+
efdRetryOnlyGroups.push(group)
|
|
989
|
+
}
|
|
505
990
|
}
|
|
991
|
+
|
|
992
|
+
return [...groupsWithOriginalTests, ...efdRetryOnlyGroups]
|
|
506
993
|
}
|
|
507
994
|
|
|
508
|
-
function
|
|
995
|
+
function prepareDispatcherRun (dispatcher, args) {
|
|
996
|
+
let testGroups = args[0]
|
|
997
|
+
|
|
998
|
+
// Filter out disabled tests from testGroups before they get scheduled,
|
|
999
|
+
// unless they have attemptToFix (in which case they should still run and be retried)
|
|
1000
|
+
if (isTestManagementTestsEnabled) {
|
|
1001
|
+
for (const group of testGroups) {
|
|
1002
|
+
group.tests = group.tests.filter(test => !test._ddIsDisabled || test._ddIsAttemptToFix)
|
|
1003
|
+
}
|
|
1004
|
+
// Remove empty groups
|
|
1005
|
+
testGroups = testGroups.filter(group => group.tests.length > 0)
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
if (isEarlyFlakeDetectionEnabled) {
|
|
1009
|
+
testGroups = deferEfdRetryGroups(testGroups)
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
if (!dispatcher._allTests) {
|
|
1013
|
+
// Removed in https://github.com/microsoft/playwright/commit/1e52c37b254a441cccf332520f60225a5acc14c7
|
|
1014
|
+
// Not available from >=1.44.0
|
|
1015
|
+
dispatcher._ddAllTests = testGroups.flatMap(g => g.tests)
|
|
1016
|
+
}
|
|
1017
|
+
remainingTestsByFile = getTestsBySuiteFromTestGroups(testGroups)
|
|
1018
|
+
args[0] = testGroups
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
function dispatcherRunWrapperNew (run) {
|
|
509
1022
|
return function () {
|
|
510
|
-
|
|
1023
|
+
prepareDispatcherRun(this, arguments)
|
|
511
1024
|
return run.apply(this, arguments)
|
|
512
1025
|
}
|
|
513
1026
|
}
|
|
514
1027
|
|
|
515
|
-
function
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
1028
|
+
function onDispatcherCreateWorker (dispatcher, worker) {
|
|
1029
|
+
if (!worker) {
|
|
1030
|
+
return worker
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
const projects = getProjectsFromDispatcher(dispatcher)
|
|
1034
|
+
sessionProjects = projects
|
|
1035
|
+
const automaticFailureScreenshotPathsByTestId = new Map()
|
|
1036
|
+
|
|
1037
|
+
if (disabledTestIds.size && !worker[kDdPlaywrightWorkerHostInstrumented] &&
|
|
1038
|
+
typeof worker.runTestGroup === 'function') {
|
|
1039
|
+
Object.defineProperty(worker, kDdPlaywrightWorkerHostInstrumented, { value: true })
|
|
1040
|
+
shimmer.wrap(worker, 'runTestGroup', runTestGroup => function (runPayload) {
|
|
1041
|
+
// Serial retries can restore disabled tests that were filtered from the initial dispatcher groups.
|
|
1042
|
+
let disabledIds
|
|
1043
|
+
for (const { testId } of runPayload.entries) {
|
|
1044
|
+
if (disabledTestIds.has(testId)) {
|
|
1045
|
+
disabledIds ??= []
|
|
1046
|
+
disabledIds.push(testId)
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
if (disabledIds) {
|
|
1050
|
+
runPayload._ddDisabledTestIds = disabledIds
|
|
1051
|
+
}
|
|
1052
|
+
return runTestGroup.apply(this, arguments)
|
|
1053
|
+
})
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
worker.on('testBegin', ({ testId }) => {
|
|
1057
|
+
const test = getTestByTestId(dispatcher, testId)
|
|
1058
|
+
if (!test) return
|
|
1059
|
+
|
|
1060
|
+
const browser = getBrowserNameFromProjects(projects, test)
|
|
1061
|
+
const shouldCreateTestSpan = test.expectedStatus === 'skipped'
|
|
1062
|
+
testBeginHandler(test, browser, shouldCreateTestSpan)
|
|
1063
|
+
})
|
|
1064
|
+
worker.on('attach', ({ testId, path, _ddIsAutomaticFailureScreenshot }) => {
|
|
1065
|
+
if (!_ddIsAutomaticFailureScreenshot) return
|
|
1066
|
+
|
|
1067
|
+
let screenshotPaths = automaticFailureScreenshotPathsByTestId.get(testId)
|
|
1068
|
+
if (!screenshotPaths) {
|
|
1069
|
+
screenshotPaths = new Set()
|
|
1070
|
+
automaticFailureScreenshotPathsByTestId.set(testId, screenshotPaths)
|
|
1071
|
+
}
|
|
1072
|
+
screenshotPaths.add(path)
|
|
1073
|
+
})
|
|
1074
|
+
worker.on('testEnd', ({ testId, status, errors, annotations }) => {
|
|
1075
|
+
const test = getTestByTestId(dispatcher, testId)
|
|
1076
|
+
if (!test) return
|
|
1077
|
+
|
|
1078
|
+
const isTimeout = status === 'timedOut'
|
|
1079
|
+
const testStatus = STATUS_TO_TEST_STATUS[status]
|
|
1080
|
+
const shouldCreateTestSpan = test.expectedStatus === 'skipped'
|
|
1081
|
+
if (shouldCreateTestSpan && !testToCtx.has(test)) {
|
|
1082
|
+
testBeginHandler(test, getBrowserNameFromProjects(projects, test), true)
|
|
1083
|
+
}
|
|
1084
|
+
testEndHandler(
|
|
1085
|
+
{
|
|
1086
|
+
test,
|
|
1087
|
+
annotations,
|
|
1088
|
+
testStatus,
|
|
1089
|
+
error: errors && errors[0],
|
|
1090
|
+
isTimeout,
|
|
1091
|
+
shouldCreateTestSpan,
|
|
1092
|
+
projects,
|
|
1093
|
+
}
|
|
1094
|
+
)
|
|
1095
|
+
const testResult = test.results.at(-1)
|
|
1096
|
+
const automaticFailureScreenshotPaths = automaticFailureScreenshotPathsByTestId.get(testId)
|
|
1097
|
+
automaticFailureScreenshotPathsByTestId.delete(testId)
|
|
1098
|
+
if (testStatus === 'fail' && automaticFailureScreenshotPaths?.size && testResult?.attachments?.length) {
|
|
1099
|
+
const screenshots = []
|
|
1100
|
+
for (const attachment of testResult.attachments) {
|
|
1101
|
+
if (automaticFailureScreenshotPaths.has(attachment.path)) {
|
|
1102
|
+
screenshots.push(attachment)
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
if (screenshots.length) {
|
|
1106
|
+
worker[kDdPlaywrightFailureScreenshots] ??= []
|
|
1107
|
+
worker[kDdPlaywrightFailureScreenshots].push(screenshots)
|
|
522
1108
|
}
|
|
523
|
-
// Remove empty groups
|
|
524
|
-
testGroups = testGroups.filter(group => group.tests.length > 0)
|
|
525
1109
|
}
|
|
1110
|
+
const isAtrRetry = testResult?.retry > 0 &&
|
|
1111
|
+
isFlakyTestRetriesEnabled &&
|
|
1112
|
+
!test._ddIsAttemptToFix &&
|
|
1113
|
+
!test._ddIsEfdRetry
|
|
526
1114
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
1115
|
+
// EFD retries (new or modified tests) are implemented as clones with retries=0,
|
|
1116
|
+
// so testWillRetry always returns false for them. Instead, we track how many
|
|
1117
|
+
// executions have been reported via testsToTestStatuses (updated by testEndHandler
|
|
1118
|
+
// above) and mark the execution final once the count reaches the expected total.
|
|
1119
|
+
// This mirrors how ATF finality is detected and centralizes the decision in the
|
|
1120
|
+
// main process, so workers only need to act on the _ddIsFinalExecution flag.
|
|
1121
|
+
const isEfdManagedTest = isTestEfdManaged(test)
|
|
1122
|
+
let isFinalExecution
|
|
1123
|
+
if (isEfdManagedTest) {
|
|
1124
|
+
const efdTestStatuses = testsToTestStatuses.get(getTestEfdKey(test)) || []
|
|
1125
|
+
isFinalExecution = efdTestStatuses.length === getEfdRetryCountForTest(test) + 1
|
|
1126
|
+
} else if (test._ddIsAttemptToFix) {
|
|
1127
|
+
isFinalExecution = !!(test._ddHasPassedAttemptToFixRetries || test._ddHasFailedAttemptToFixRetries)
|
|
1128
|
+
} else {
|
|
1129
|
+
isFinalExecution = !testWillRetry(test, testStatus)
|
|
531
1130
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
1131
|
+
|
|
1132
|
+
const ddProperties = {
|
|
1133
|
+
_ddIsDisabled: test._ddIsDisabled,
|
|
1134
|
+
_ddIsQuarantined: test._ddIsQuarantined,
|
|
1135
|
+
_ddIsAttemptToFix: test._ddIsAttemptToFix,
|
|
1136
|
+
_ddIsAttemptToFixRetry: test._ddIsAttemptToFixRetry,
|
|
1137
|
+
_ddIsNew: test._ddIsNew,
|
|
1138
|
+
_ddIsEfdRetry: test._ddIsEfdRetry,
|
|
1139
|
+
_ddHasFailedAllRetries: test._ddHasFailedAllRetries,
|
|
1140
|
+
_ddHasPassedAttemptToFixRetries: test._ddHasPassedAttemptToFixRetries,
|
|
1141
|
+
_ddHasFailedAttemptToFixRetries: test._ddHasFailedAttemptToFixRetries,
|
|
1142
|
+
_ddIsAtrRetry: isAtrRetry,
|
|
1143
|
+
_ddIsModified: test._ddIsModified,
|
|
1144
|
+
_ddIsFinalExecution: isFinalExecution,
|
|
1145
|
+
_ddIsEfdManagedTest: isEfdManagedTest,
|
|
1146
|
+
_ddEarlyFlakeAbortReason: efdSlowAbortedTests.has(getTestEfdKey(test)) ? 'slow' : undefined,
|
|
1147
|
+
_ddHasPassedAnyEfdAttempt: (testsToTestStatuses.get(getTestEfdKey(test)) || []).includes('pass'),
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
setDdPropertiesForTest(worker.process, test.id, ddProperties)
|
|
1151
|
+
})
|
|
1152
|
+
|
|
1153
|
+
return worker
|
|
535
1154
|
}
|
|
536
1155
|
|
|
537
1156
|
function dispatcherHook (dispatcherExport) {
|
|
538
1157
|
shimmer.wrap(dispatcherExport.Dispatcher.prototype, 'run', dispatcherRunWrapper)
|
|
539
|
-
shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function () {
|
|
1158
|
+
shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function (...args) {
|
|
540
1159
|
const dispatcher = this
|
|
541
|
-
const worker = createWorker.apply(this,
|
|
1160
|
+
const worker = createWorker.apply(this, args)
|
|
542
1161
|
const projects = getProjectsFromDispatcher(dispatcher)
|
|
543
1162
|
sessionProjects = projects
|
|
544
1163
|
|
|
@@ -569,7 +1188,6 @@ function dispatcherHook (dispatcherExport) {
|
|
|
569
1188
|
)
|
|
570
1189
|
}
|
|
571
1190
|
})
|
|
572
|
-
|
|
573
1191
|
return worker
|
|
574
1192
|
})
|
|
575
1193
|
return dispatcherExport
|
|
@@ -577,60 +1195,10 @@ function dispatcherHook (dispatcherExport) {
|
|
|
577
1195
|
|
|
578
1196
|
function dispatcherHookNew (dispatcherExport, runWrapper) {
|
|
579
1197
|
shimmer.wrap(dispatcherExport.Dispatcher.prototype, 'run', runWrapper)
|
|
580
|
-
shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function () {
|
|
1198
|
+
shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function (...args) {
|
|
581
1199
|
const dispatcher = this
|
|
582
|
-
const worker = createWorker.apply(this,
|
|
583
|
-
|
|
584
|
-
sessionProjects = projects
|
|
585
|
-
|
|
586
|
-
worker.on('testBegin', ({ testId }) => {
|
|
587
|
-
const test = getTestByTestId(dispatcher, testId)
|
|
588
|
-
const browser = getBrowserNameFromProjects(projects, test)
|
|
589
|
-
const shouldCreateTestSpan = test.expectedStatus === 'skipped'
|
|
590
|
-
testBeginHandler(test, browser, shouldCreateTestSpan)
|
|
591
|
-
})
|
|
592
|
-
worker.on('testEnd', ({ testId, status, errors, annotations }) => {
|
|
593
|
-
const test = getTestByTestId(dispatcher, testId)
|
|
594
|
-
|
|
595
|
-
const isTimeout = status === 'timedOut'
|
|
596
|
-
const shouldCreateTestSpan = test.expectedStatus === 'skipped'
|
|
597
|
-
testEndHandler(
|
|
598
|
-
{
|
|
599
|
-
test,
|
|
600
|
-
annotations,
|
|
601
|
-
testStatus: STATUS_TO_TEST_STATUS[status],
|
|
602
|
-
error: errors && errors[0],
|
|
603
|
-
isTimeout,
|
|
604
|
-
shouldCreateTestSpan,
|
|
605
|
-
projects,
|
|
606
|
-
}
|
|
607
|
-
)
|
|
608
|
-
const testResult = test.results.at(-1)
|
|
609
|
-
const isAtrRetry = testResult?.retry > 0 &&
|
|
610
|
-
isFlakyTestRetriesEnabled &&
|
|
611
|
-
!test._ddIsAttemptToFix &&
|
|
612
|
-
!test._ddIsEfdRetry
|
|
613
|
-
// We want to send the ddProperties to the worker
|
|
614
|
-
worker.process.send({
|
|
615
|
-
type: 'ddProperties',
|
|
616
|
-
testId: test.id,
|
|
617
|
-
properties: {
|
|
618
|
-
_ddIsDisabled: test._ddIsDisabled,
|
|
619
|
-
_ddIsQuarantined: test._ddIsQuarantined,
|
|
620
|
-
_ddIsAttemptToFix: test._ddIsAttemptToFix,
|
|
621
|
-
_ddIsAttemptToFixRetry: test._ddIsAttemptToFixRetry,
|
|
622
|
-
_ddIsNew: test._ddIsNew,
|
|
623
|
-
_ddIsEfdRetry: test._ddIsEfdRetry,
|
|
624
|
-
_ddHasFailedAllRetries: test._ddHasFailedAllRetries,
|
|
625
|
-
_ddHasPassedAttemptToFixRetries: test._ddHasPassedAttemptToFixRetries,
|
|
626
|
-
_ddHasFailedAttemptToFixRetries: test._ddHasFailedAttemptToFixRetries,
|
|
627
|
-
_ddIsAtrRetry: isAtrRetry,
|
|
628
|
-
_ddIsModified: test._ddIsModified,
|
|
629
|
-
},
|
|
630
|
-
})
|
|
631
|
-
})
|
|
632
|
-
|
|
633
|
-
return worker
|
|
1200
|
+
const worker = createWorker.apply(this, args)
|
|
1201
|
+
return onDispatcherCreateWorker(dispatcher, worker)
|
|
634
1202
|
})
|
|
635
1203
|
return dispatcherExport
|
|
636
1204
|
}
|
|
@@ -641,10 +1209,16 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
641
1209
|
let onDone
|
|
642
1210
|
|
|
643
1211
|
rootDir = getRootDir(this, config)
|
|
644
|
-
|
|
1212
|
+
const projects = getProjectsFromRunner(this, config)
|
|
1213
|
+
const isFailureScreenshotEnabled = isFailureScreenshotCaptureEnabled(projects)
|
|
645
1214
|
const processArgv = process.argv.slice(2).join(' ')
|
|
646
1215
|
const command = `playwright ${processArgv}`
|
|
647
|
-
testSessionStartCh.publish({
|
|
1216
|
+
testSessionStartCh.publish({
|
|
1217
|
+
command,
|
|
1218
|
+
frameworkVersion: playwrightVersion,
|
|
1219
|
+
rootDir,
|
|
1220
|
+
isFailureScreenshotEnabled,
|
|
1221
|
+
})
|
|
648
1222
|
|
|
649
1223
|
try {
|
|
650
1224
|
const { err, libraryConfig } = await getChannelPromise(
|
|
@@ -655,6 +1229,7 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
655
1229
|
isKnownTestsEnabled = libraryConfig.isKnownTestsEnabled
|
|
656
1230
|
isEarlyFlakeDetectionEnabled = libraryConfig.isEarlyFlakeDetectionEnabled
|
|
657
1231
|
earlyFlakeDetectionNumRetries = libraryConfig.earlyFlakeDetectionNumRetries
|
|
1232
|
+
earlyFlakeDetectionSlowTestRetries = libraryConfig.earlyFlakeDetectionSlowTestRetries ?? {}
|
|
658
1233
|
earlyFlakeDetectionFaultyThreshold = libraryConfig.earlyFlakeDetectionFaultyThreshold
|
|
659
1234
|
isFlakyTestRetriesEnabled = libraryConfig.isFlakyTestRetriesEnabled
|
|
660
1235
|
flakyTestRetriesCount = libraryConfig.flakyTestRetriesCount
|
|
@@ -670,9 +1245,26 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
670
1245
|
log.error('Playwright session start error', e)
|
|
671
1246
|
}
|
|
672
1247
|
|
|
673
|
-
|
|
1248
|
+
testSessionConfigurationCh.publish({ isFailureScreenshotEnabled })
|
|
1249
|
+
|
|
1250
|
+
const isTestOptimizationSupported = satisfies(playwrightVersion, MINIMUM_SUPPORTED_VERSION_RANGE_EFD)
|
|
1251
|
+
const shouldGetKnownTests = isKnownTestsEnabled && isTestOptimizationSupported
|
|
1252
|
+
const shouldGetTestManagementTests = isTestManagementTestsEnabled && isTestOptimizationSupported
|
|
1253
|
+
|
|
1254
|
+
const {
|
|
1255
|
+
knownTestsResponse,
|
|
1256
|
+
testManagementTestsResponse,
|
|
1257
|
+
} = await getTestOptimizationRequestResults({
|
|
1258
|
+
isKnownTestsEnabled: shouldGetKnownTests,
|
|
1259
|
+
isTestManagementTestsEnabled: shouldGetTestManagementTests,
|
|
1260
|
+
getKnownTests: () => getChannelPromise(knownTestsCh),
|
|
1261
|
+
getTestManagementTests: () => getChannelPromise(testManagementTestsCh),
|
|
1262
|
+
})
|
|
1263
|
+
|
|
1264
|
+
if (shouldGetKnownTests) {
|
|
674
1265
|
try {
|
|
675
|
-
const { err, knownTests: receivedKnownTests } =
|
|
1266
|
+
const { err, knownTests: receivedKnownTests } =
|
|
1267
|
+
knownTestsResponse || await getChannelPromise(knownTestsCh)
|
|
676
1268
|
if (err) {
|
|
677
1269
|
isEarlyFlakeDetectionEnabled = false
|
|
678
1270
|
isKnownTestsEnabled = false
|
|
@@ -691,9 +1283,10 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
691
1283
|
}
|
|
692
1284
|
}
|
|
693
1285
|
|
|
694
|
-
if (
|
|
1286
|
+
if (shouldGetTestManagementTests) {
|
|
695
1287
|
try {
|
|
696
|
-
const { err, testManagementTests: receivedTestManagementTests } =
|
|
1288
|
+
const { err, testManagementTests: receivedTestManagementTests } =
|
|
1289
|
+
testManagementTestsResponse || await getChannelPromise(testManagementTestsCh)
|
|
697
1290
|
if (err) {
|
|
698
1291
|
isTestManagementTestsEnabled = false
|
|
699
1292
|
} else {
|
|
@@ -705,7 +1298,7 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
705
1298
|
}
|
|
706
1299
|
}
|
|
707
1300
|
|
|
708
|
-
if (isImpactedTestsEnabled &&
|
|
1301
|
+
if (isImpactedTestsEnabled && isTestOptimizationSupported) {
|
|
709
1302
|
try {
|
|
710
1303
|
const { err, modifiedFiles: receivedModifiedFiles } = await getChannelPromise(modifiedFilesCh)
|
|
711
1304
|
if (err) {
|
|
@@ -719,8 +1312,6 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
719
1312
|
}
|
|
720
1313
|
}
|
|
721
1314
|
|
|
722
|
-
const projects = getProjectsFromRunner(this, config)
|
|
723
|
-
|
|
724
1315
|
// ATR and `--retries` are now compatible with Test Management.
|
|
725
1316
|
// Test Management tests have their retries set to 0 at the test level,
|
|
726
1317
|
// preventing them from being retried by ATR or `--retries`.
|
|
@@ -743,15 +1334,16 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
743
1334
|
// there were tests that did not go through `testBegin` or `testEnd`,
|
|
744
1335
|
// because they were skipped
|
|
745
1336
|
for (const test of tests) {
|
|
1337
|
+
const alreadyReported = testsReportedInGenerateSummary.has(test)
|
|
746
1338
|
const browser = getBrowserNameFromProjects(projects, test)
|
|
747
|
-
testBeginHandler(test, browser,
|
|
1339
|
+
testBeginHandler(test, browser, !alreadyReported)
|
|
748
1340
|
testEndHandler({
|
|
749
1341
|
test,
|
|
750
1342
|
annotations: [],
|
|
751
1343
|
testStatus: 'skip',
|
|
752
1344
|
error: null,
|
|
753
1345
|
isTimeout: false,
|
|
754
|
-
shouldCreateTestSpan:
|
|
1346
|
+
shouldCreateTestSpan: !alreadyReported,
|
|
755
1347
|
projects,
|
|
756
1348
|
})
|
|
757
1349
|
}
|
|
@@ -763,12 +1355,11 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
763
1355
|
|
|
764
1356
|
if (isTestManagementTestsEnabled && sessionStatus === 'failed') {
|
|
765
1357
|
let totalFailedTestCount = 0
|
|
766
|
-
let totalAttemptToFixFailedTestCount = 0
|
|
767
1358
|
let totalPureQuarantinedFailedTestCount = 0
|
|
768
1359
|
|
|
769
1360
|
for (const [fqn, testStatuses] of testsToTestStatuses.entries()) {
|
|
770
1361
|
// Only count as failed if the final status (after retries) is 'fail'
|
|
771
|
-
const lastStatus = testStatuses
|
|
1362
|
+
const lastStatus = testStatuses.at(-1)
|
|
772
1363
|
if (lastStatus === 'fail') {
|
|
773
1364
|
totalFailedTestCount += 1
|
|
774
1365
|
if (quarantinedButNotAttemptToFixFqns.has(fqn)) {
|
|
@@ -777,16 +1368,7 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
777
1368
|
}
|
|
778
1369
|
}
|
|
779
1370
|
|
|
780
|
-
|
|
781
|
-
const testFqn = getTestFullyQualifiedName(test)
|
|
782
|
-
const testStatuses = testsToTestStatuses.get(testFqn)
|
|
783
|
-
// Only count as failed if the final status (after retries) is 'fail'
|
|
784
|
-
if (testStatuses && testStatuses[testStatuses.length - 1] === 'fail') {
|
|
785
|
-
totalAttemptToFixFailedTestCount += 1
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
const totalIgnorableFailures = totalAttemptToFixFailedTestCount + totalPureQuarantinedFailedTestCount
|
|
1371
|
+
const totalIgnorableFailures = totalPureQuarantinedFailedTestCount
|
|
790
1372
|
|
|
791
1373
|
if (totalFailedTestCount > 0 && totalFailedTestCount === totalIgnorableFailures) {
|
|
792
1374
|
runAllTestsReturn = 'passed'
|
|
@@ -794,7 +1376,8 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
794
1376
|
}
|
|
795
1377
|
}
|
|
796
1378
|
|
|
797
|
-
|
|
1379
|
+
logTestOptimizationSummary({ attemptToFixExecutions, newTestsWithDynamicNames })
|
|
1380
|
+
loggedAttemptToFixTests.clear()
|
|
798
1381
|
|
|
799
1382
|
const flushWait = new Promise(resolve => {
|
|
800
1383
|
onDone = resolve
|
|
@@ -811,6 +1394,17 @@ function runAllTestsWrapper (runAllTests, playwrightVersion) {
|
|
|
811
1394
|
startedSuites = []
|
|
812
1395
|
remainingTestsByFile = {}
|
|
813
1396
|
quarantinedButNotAttemptToFixFqns = new Set()
|
|
1397
|
+
testsReportedInGenerateSummary = new Set()
|
|
1398
|
+
efdManagedTestKeys.clear()
|
|
1399
|
+
efdRetryCountByTestKey.clear()
|
|
1400
|
+
efdRetryCountRequestsByTestKey.clear()
|
|
1401
|
+
efdRetryTestsById.clear()
|
|
1402
|
+
efdScheduledOriginalTestKeys.clear()
|
|
1403
|
+
efdStartedOriginalTestKeys.clear()
|
|
1404
|
+
efdSlowAbortedTests.clear()
|
|
1405
|
+
ddPropertiesByTestId.clear()
|
|
1406
|
+
ddPropertiesRequestsByTestId.clear()
|
|
1407
|
+
disabledTestIds.clear()
|
|
814
1408
|
|
|
815
1409
|
// TODO: we can trick playwright into thinking the session passed by returning
|
|
816
1410
|
// 'passed' here. We might be able to use this for both EFD and Test Management tests.
|
|
@@ -837,6 +1431,102 @@ function runnerHookNew (runnerExport, playwrightVersion) {
|
|
|
837
1431
|
return runnerExport
|
|
838
1432
|
}
|
|
839
1433
|
|
|
1434
|
+
function runnerIndexHook (runnerExport, playwrightVersion) {
|
|
1435
|
+
let wrappedTestRunner
|
|
1436
|
+
runnerExport = shimmer.wrap(runnerExport, 'testRunner', function (originalGetter) {
|
|
1437
|
+
return function () {
|
|
1438
|
+
if (!wrappedTestRunner) {
|
|
1439
|
+
wrappedTestRunner = runnerHookNew(originalGetter.call(this), playwrightVersion)
|
|
1440
|
+
}
|
|
1441
|
+
return wrappedTestRunner
|
|
1442
|
+
}
|
|
1443
|
+
})
|
|
1444
|
+
|
|
1445
|
+
const baseReporter = runnerExport.base?.TerminalReporter
|
|
1446
|
+
if (baseReporter) {
|
|
1447
|
+
shimmer.wrap(baseReporter.prototype, 'generateSummary', generateSummaryWrapper)
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
return runnerExport
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
function commonIndexHook (commonExport) {
|
|
1454
|
+
applyRepeatEachIndex = commonExport.suiteUtils?.applyRepeatEachIndex
|
|
1455
|
+
|
|
1456
|
+
let wrappedStartProcessRunner
|
|
1457
|
+
commonExport = shimmer.wrap(commonExport, 'startProcessRunner', function (originalGetter) {
|
|
1458
|
+
return function () {
|
|
1459
|
+
if (!wrappedStartProcessRunner) {
|
|
1460
|
+
const startProcessRunner = originalGetter.call(this)
|
|
1461
|
+
wrappedStartProcessRunner = function (create) {
|
|
1462
|
+
return startProcessRunner.call(this, function () {
|
|
1463
|
+
const processRunner = create.apply(this, arguments)
|
|
1464
|
+
instrumentWorkerMainMethods(processRunner)
|
|
1465
|
+
return processRunner
|
|
1466
|
+
})
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
return wrappedStartProcessRunner
|
|
1470
|
+
}
|
|
1471
|
+
})
|
|
1472
|
+
|
|
1473
|
+
return commonExport
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
dispatcherRunCh.subscribe({
|
|
1477
|
+
start (ctx) {
|
|
1478
|
+
prepareDispatcherRun(ctx.self, ctx.arguments)
|
|
1479
|
+
},
|
|
1480
|
+
})
|
|
1481
|
+
|
|
1482
|
+
dispatcherCreateWorkerCh.subscribe({
|
|
1483
|
+
end (ctx) {
|
|
1484
|
+
onDispatcherCreateWorker(ctx.self, ctx.result)
|
|
1485
|
+
},
|
|
1486
|
+
})
|
|
1487
|
+
|
|
1488
|
+
processHostStartRunnerCh.subscribe({
|
|
1489
|
+
start (ctx) {
|
|
1490
|
+
prepareProcessHostStartRunner(ctx.self)
|
|
1491
|
+
},
|
|
1492
|
+
asyncEnd (ctx) {
|
|
1493
|
+
finishProcessHostStartRunner(ctx.self)
|
|
1494
|
+
},
|
|
1495
|
+
})
|
|
1496
|
+
|
|
1497
|
+
createRootSuiteCh.subscribe({
|
|
1498
|
+
asyncEnd (ctx) {
|
|
1499
|
+
if (ctx.error) {
|
|
1500
|
+
return
|
|
1501
|
+
}
|
|
1502
|
+
processRootSuite(ctx.result || ctx.arguments?.[0])
|
|
1503
|
+
},
|
|
1504
|
+
})
|
|
1505
|
+
|
|
1506
|
+
pageGotoCh.subscribe({
|
|
1507
|
+
asyncEnd (ctx) {
|
|
1508
|
+
// The Page.goto rewriter waits for this so tests closing immediately after navigation still get RUM tags.
|
|
1509
|
+
ctx.asyncEndPromise = handlePageGoto(ctx.self)
|
|
1510
|
+
},
|
|
1511
|
+
})
|
|
1512
|
+
|
|
1513
|
+
/**
|
|
1514
|
+
* Records a path created by Playwright's automatic screenshot recorder.
|
|
1515
|
+
*
|
|
1516
|
+
* @param {object} ctx - Orchestrion context
|
|
1517
|
+
* @returns {void}
|
|
1518
|
+
*/
|
|
1519
|
+
function recordAutomaticFailureScreenshotPath (ctx) {
|
|
1520
|
+
if (isFailureScreenshotUploadEnabled &&
|
|
1521
|
+
typeof ctx.result === 'string' &&
|
|
1522
|
+
PLAYWRIGHT_FAILURE_SCREENSHOT_PATH_RE.test(ctx.result)) {
|
|
1523
|
+
automaticFailureScreenshotPaths.add(ctx.result)
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
artifactsRecorderScreenshotPathCh.subscribe({ end: recordAutomaticFailureScreenshotPath })
|
|
1528
|
+
snapshotRecorderScreenshotPathCh.subscribe({ end: recordAutomaticFailureScreenshotPath })
|
|
1529
|
+
|
|
840
1530
|
if (DD_MAJOR < 6) { // <1.38.0 is only supported up to version 5
|
|
841
1531
|
addHook({
|
|
842
1532
|
name: '@playwright/test',
|
|
@@ -869,28 +1559,40 @@ if (DD_MAJOR < 6) { // <1.38.0 is only supported up to version 5
|
|
|
869
1559
|
}, runnerHook)
|
|
870
1560
|
}
|
|
871
1561
|
|
|
1562
|
+
addHook({
|
|
1563
|
+
name: 'playwright',
|
|
1564
|
+
file: 'lib/runner/index.js',
|
|
1565
|
+
versions: ['>=1.60.0'],
|
|
1566
|
+
}, runnerIndexHook)
|
|
1567
|
+
|
|
1568
|
+
addHook({
|
|
1569
|
+
name: 'playwright',
|
|
1570
|
+
file: 'lib/common/index.js',
|
|
1571
|
+
versions: ['>=1.60.0'],
|
|
1572
|
+
}, commonIndexHook)
|
|
1573
|
+
|
|
872
1574
|
addHook({
|
|
873
1575
|
name: 'playwright',
|
|
874
1576
|
file: 'lib/runner/runner.js',
|
|
875
|
-
versions: ['>=1.38.0'],
|
|
1577
|
+
versions: ['>=1.38.0 <1.60.0'],
|
|
876
1578
|
}, runnerHook)
|
|
877
1579
|
|
|
878
1580
|
addHook({
|
|
879
1581
|
name: 'playwright',
|
|
880
1582
|
file: 'lib/runner/testRunner.js',
|
|
881
|
-
versions: ['>=1.55.0'],
|
|
1583
|
+
versions: ['>=1.55.0 <1.60.0'],
|
|
882
1584
|
}, runnerHookNew)
|
|
883
1585
|
|
|
884
1586
|
addHook({
|
|
885
1587
|
name: 'playwright',
|
|
886
1588
|
file: 'lib/runner/dispatcher.js',
|
|
887
|
-
versions: ['>=1.38.0'],
|
|
1589
|
+
versions: ['>=1.38.0 <1.60.0'],
|
|
888
1590
|
}, (dispatcher) => dispatcherHookNew(dispatcher, dispatcherRunWrapperNew))
|
|
889
1591
|
|
|
890
1592
|
addHook({
|
|
891
1593
|
name: 'playwright',
|
|
892
1594
|
file: 'lib/common/suiteUtils.js',
|
|
893
|
-
versions: ['>=1.38.0'],
|
|
1595
|
+
versions: ['>=1.38.0 <1.60.0'],
|
|
894
1596
|
}, suiteUtilsPackage => {
|
|
895
1597
|
// We grab `applyRepeatEachIndex` to use it later
|
|
896
1598
|
// `applyRepeatEachIndex` needs to be applied to a cloned suite
|
|
@@ -912,159 +1614,196 @@ addHook({
|
|
|
912
1614
|
* - we execute `applyRepeatEachIndex` for each of these cloned file suites
|
|
913
1615
|
* - we add the cloned file suites to the project suite
|
|
914
1616
|
*/
|
|
915
|
-
function applyRetriesToTests (
|
|
1617
|
+
function applyRetriesToTests (
|
|
1618
|
+
fileSuitesWithTestsToRetry,
|
|
1619
|
+
filterTest,
|
|
1620
|
+
tagsToApply,
|
|
1621
|
+
numRetries,
|
|
1622
|
+
configureCopiedTest,
|
|
1623
|
+
getRetryRepeatEachIndex
|
|
1624
|
+
) {
|
|
916
1625
|
for (const [fileSuite, projectSuite] of fileSuitesWithTestsToRetry.entries()) {
|
|
917
1626
|
for (let repeatEachIndex = 1; repeatEachIndex <= numRetries; repeatEachIndex++) {
|
|
918
|
-
const copyFileSuite = deepCloneSuite(fileSuite, filterTest, tagsToApply)
|
|
919
|
-
|
|
1627
|
+
const copyFileSuite = deepCloneSuite(fileSuite, filterTest, tagsToApply, (copiedTest, originalTest) => {
|
|
1628
|
+
if (configureCopiedTest) {
|
|
1629
|
+
configureCopiedTest(copiedTest, originalTest, repeatEachIndex)
|
|
1630
|
+
}
|
|
1631
|
+
})
|
|
1632
|
+
const retryRepeatEachIndex = getRetryRepeatEachIndex
|
|
1633
|
+
? getRetryRepeatEachIndex(fileSuite, projectSuite, repeatEachIndex, numRetries)
|
|
1634
|
+
: repeatEachIndex + 1
|
|
1635
|
+
applyRepeatEachIndex(projectSuite._fullProject, copyFileSuite, retryRepeatEachIndex)
|
|
920
1636
|
projectSuite._addSuite(copyFileSuite)
|
|
1637
|
+
for (const copiedTest of copyFileSuite.allTests()) {
|
|
1638
|
+
registerEfdRetryTest(copiedTest)
|
|
1639
|
+
}
|
|
921
1640
|
}
|
|
922
1641
|
}
|
|
923
1642
|
}
|
|
924
1643
|
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
}, (loadUtilsPackage) => {
|
|
930
|
-
const oldCreateRootSuite = loadUtilsPackage.createRootSuite
|
|
1644
|
+
function processRootSuite (createRootSuiteReturnValue) {
|
|
1645
|
+
if (!isKnownTestsEnabled && !isTestManagementTestsEnabled && !isImpactedTestsEnabled) {
|
|
1646
|
+
return createRootSuiteReturnValue
|
|
1647
|
+
}
|
|
931
1648
|
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
}
|
|
1649
|
+
if (!createRootSuiteReturnValue) {
|
|
1650
|
+
return createRootSuiteReturnValue
|
|
1651
|
+
}
|
|
936
1652
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
1653
|
+
// From v1.56.0 on, createRootSuite returns `{ rootSuite, topLevelProjects }`
|
|
1654
|
+
const rootSuite = createRootSuiteReturnValue.rootSuite || createRootSuiteReturnValue
|
|
1655
|
+
if (typeof rootSuite?.allTests !== 'function') {
|
|
1656
|
+
return createRootSuiteReturnValue
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
const allTests = rootSuite.allTests()
|
|
1660
|
+
|
|
1661
|
+
if (isTestManagementTestsEnabled) {
|
|
1662
|
+
const fileSuitesWithManagedTestsToProjects = new Map()
|
|
1663
|
+
for (const test of allTests) {
|
|
1664
|
+
const testProperties = getTestProperties(test)
|
|
1665
|
+
// Disabled tests are skipped unless they have attemptToFix
|
|
1666
|
+
if (testProperties.disabled) {
|
|
1667
|
+
test._ddIsDisabled = true
|
|
1668
|
+
if (!testProperties.attemptToFix) {
|
|
1669
|
+
disabledTestIds.add(test.id)
|
|
1670
|
+
test.expectedStatus = 'skipped'
|
|
1671
|
+
// setting test.expectedStatus to 'skipped' does not work for every case,
|
|
1672
|
+
// so we need to filter out disabled tests in dispatcherRunWrapperNew,
|
|
1673
|
+
// so they don't get to the workers
|
|
1674
|
+
continue
|
|
957
1675
|
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1676
|
+
}
|
|
1677
|
+
if (testProperties.quarantined) {
|
|
1678
|
+
test._ddIsQuarantined = true
|
|
1679
|
+
if (!testProperties.attemptToFix) {
|
|
1680
|
+
// Do not skip quarantined tests, let them run and overwrite results post-run if they fail
|
|
1681
|
+
const testFqn = getTestFullyQualifiedName(test)
|
|
1682
|
+
quarantinedButNotAttemptToFixFqns.add(testFqn)
|
|
965
1683
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
if (testProperties.disabled || testProperties.quarantined) {
|
|
976
|
-
quarantinedOrDisabledTestsAttemptToFix.push(test)
|
|
977
|
-
}
|
|
1684
|
+
}
|
|
1685
|
+
if (testProperties.attemptToFix) {
|
|
1686
|
+
test._ddIsAttemptToFix = true
|
|
1687
|
+
// Prevent ATR or `--retries` from retrying attemptToFix tests
|
|
1688
|
+
test.retries = 0
|
|
1689
|
+
const fileSuite = getSuiteType(test, 'file')
|
|
1690
|
+
|
|
1691
|
+
if (!fileSuitesWithManagedTestsToProjects.has(fileSuite)) {
|
|
1692
|
+
fileSuitesWithManagedTestsToProjects.set(fileSuite, getSuiteType(test, 'project'))
|
|
978
1693
|
}
|
|
979
1694
|
}
|
|
980
|
-
applyRetriesToTests(
|
|
981
|
-
fileSuitesWithManagedTestsToProjects,
|
|
982
|
-
(test) => test._ddIsAttemptToFix,
|
|
983
|
-
[
|
|
984
|
-
(test) => test._ddIsQuarantined && '_ddIsQuarantined',
|
|
985
|
-
(test) => test._ddIsDisabled && '_ddIsDisabled',
|
|
986
|
-
'_ddIsAttemptToFix',
|
|
987
|
-
'_ddIsAttemptToFixRetry',
|
|
988
|
-
],
|
|
989
|
-
testManagementAttemptToFixRetries
|
|
990
|
-
)
|
|
991
1695
|
}
|
|
1696
|
+
applyRetriesToTests(
|
|
1697
|
+
fileSuitesWithManagedTestsToProjects,
|
|
1698
|
+
(test) => test._ddIsAttemptToFix,
|
|
1699
|
+
[
|
|
1700
|
+
(test) => test._ddIsQuarantined && '_ddIsQuarantined',
|
|
1701
|
+
(test) => test._ddIsDisabled && '_ddIsDisabled',
|
|
1702
|
+
'_ddIsAttemptToFix',
|
|
1703
|
+
'_ddIsAttemptToFixRetry',
|
|
1704
|
+
],
|
|
1705
|
+
testManagementAttemptToFixRetries
|
|
1706
|
+
)
|
|
1707
|
+
}
|
|
992
1708
|
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
})
|
|
1001
|
-
return isImpacted
|
|
1709
|
+
if (isImpactedTestsEnabled) {
|
|
1710
|
+
const impactedTests = allTests.filter(test => {
|
|
1711
|
+
let isImpacted = false
|
|
1712
|
+
isModifiedCh.publish({
|
|
1713
|
+
filePath: test._requireFile,
|
|
1714
|
+
modifiedFiles,
|
|
1715
|
+
onDone: (isModified) => { isImpacted = isModified },
|
|
1002
1716
|
})
|
|
1717
|
+
return isImpacted
|
|
1718
|
+
})
|
|
1003
1719
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1720
|
+
const fileSuitesWithImpactedTestsToProjects = new Map()
|
|
1721
|
+
for (const impactedTest of impactedTests) {
|
|
1722
|
+
impactedTest._ddIsModified = true
|
|
1723
|
+
if (isEarlyFlakeDetectionEnabled && impactedTest.expectedStatus !== 'skipped') {
|
|
1724
|
+
markEfdManagedTest(impactedTest)
|
|
1725
|
+
const fileSuite = getSuiteType(impactedTest, 'file')
|
|
1726
|
+
if (!fileSuitesWithImpactedTestsToProjects.has(fileSuite)) {
|
|
1727
|
+
fileSuitesWithImpactedTestsToProjects.set(fileSuite, getSuiteType(impactedTest, 'project'))
|
|
1012
1728
|
}
|
|
1013
1729
|
}
|
|
1014
|
-
// If something change in the file, all tests in the file are impacted, hence the () => true filter
|
|
1015
|
-
applyRetriesToTests(
|
|
1016
|
-
fileSuitesWithImpactedTestsToProjects,
|
|
1017
|
-
() => true,
|
|
1018
|
-
[
|
|
1019
|
-
'_ddIsModified',
|
|
1020
|
-
'_ddIsEfdRetry',
|
|
1021
|
-
(test) => (isKnownTestsEnabled && isNewTest(test) ? '_ddIsNew' : null),
|
|
1022
|
-
],
|
|
1023
|
-
earlyFlakeDetectionNumRetries
|
|
1024
|
-
)
|
|
1025
1730
|
}
|
|
1731
|
+
// If something change in the file, all tests in the file are impacted, hence the () => true filter
|
|
1732
|
+
applyRetriesToTests(
|
|
1733
|
+
fileSuitesWithImpactedTestsToProjects,
|
|
1734
|
+
() => true,
|
|
1735
|
+
[
|
|
1736
|
+
'_ddIsModified',
|
|
1737
|
+
'_ddIsEfdRetry',
|
|
1738
|
+
(test) => (isKnownTestsEnabled && isNewTest(test) ? '_ddIsNew' : null),
|
|
1739
|
+
],
|
|
1740
|
+
getConfiguredEfdRetryCount(),
|
|
1741
|
+
(copiedTest, originalTest, retryIndex) => {
|
|
1742
|
+
markEfdRetryTest(copiedTest, retryIndex, originalTest)
|
|
1743
|
+
markEfdManagedTest(copiedTest)
|
|
1744
|
+
},
|
|
1745
|
+
getEfdRetryRepeatEachIndex
|
|
1746
|
+
)
|
|
1747
|
+
}
|
|
1026
1748
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1749
|
+
if (isKnownTestsEnabled) {
|
|
1750
|
+
const newTests = allTests.filter(isNewTest)
|
|
1029
1751
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1752
|
+
const isFaulty = getIsFaultyEarlyFlakeDetection(
|
|
1753
|
+
allTests.map(test => getTestSuitePath(test._requireFile, rootDir)),
|
|
1754
|
+
knownTests.playwright,
|
|
1755
|
+
earlyFlakeDetectionFaultyThreshold
|
|
1756
|
+
)
|
|
1035
1757
|
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1758
|
+
if (isFaulty) {
|
|
1759
|
+
isEarlyFlakeDetectionEnabled = false
|
|
1760
|
+
isKnownTestsEnabled = false
|
|
1761
|
+
isEarlyFlakeDetectionFaulty = true
|
|
1762
|
+
} else {
|
|
1763
|
+
const fileSuitesWithNewTestsToProjects = new Map()
|
|
1764
|
+
for (const newTest of newTests) {
|
|
1765
|
+
newTest._ddIsNew = true
|
|
1766
|
+
if (isEarlyFlakeDetectionEnabled && newTest.expectedStatus !== 'skipped' && !newTest._ddIsModified) {
|
|
1767
|
+
// Prevent ATR or `--retries` from retrying new tests if EFD is enabled
|
|
1768
|
+
newTest.retries = 0
|
|
1769
|
+
markEfdManagedTest(newTest)
|
|
1770
|
+
const fileSuite = getSuiteType(newTest, 'file')
|
|
1771
|
+
if (!fileSuitesWithNewTestsToProjects.has(fileSuite)) {
|
|
1772
|
+
fileSuitesWithNewTestsToProjects.set(fileSuite, getSuiteType(newTest, 'project'))
|
|
1051
1773
|
}
|
|
1052
1774
|
}
|
|
1053
|
-
|
|
1054
|
-
applyRetriesToTests(
|
|
1055
|
-
fileSuitesWithNewTestsToProjects,
|
|
1056
|
-
isNewTest,
|
|
1057
|
-
['_ddIsNew', '_ddIsEfdRetry'],
|
|
1058
|
-
earlyFlakeDetectionNumRetries
|
|
1059
|
-
)
|
|
1060
1775
|
}
|
|
1776
|
+
|
|
1777
|
+
applyRetriesToTests(
|
|
1778
|
+
fileSuitesWithNewTestsToProjects,
|
|
1779
|
+
isNewTest,
|
|
1780
|
+
['_ddIsNew', '_ddIsEfdRetry'],
|
|
1781
|
+
getConfiguredEfdRetryCount(),
|
|
1782
|
+
(copiedTest, originalTest, retryIndex) => {
|
|
1783
|
+
markEfdRetryTest(copiedTest, retryIndex, originalTest)
|
|
1784
|
+
markEfdManagedTest(copiedTest)
|
|
1785
|
+
},
|
|
1786
|
+
getEfdRetryRepeatEachIndex
|
|
1787
|
+
)
|
|
1061
1788
|
}
|
|
1789
|
+
}
|
|
1062
1790
|
|
|
1063
|
-
|
|
1791
|
+
return createRootSuiteReturnValue
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
addHook({
|
|
1795
|
+
name: 'playwright',
|
|
1796
|
+
file: 'lib/runner/loadUtils.js',
|
|
1797
|
+
versions: ['>=1.38.0 <1.60.0'],
|
|
1798
|
+
}, (loadUtilsPackage) => {
|
|
1799
|
+
const oldCreateRootSuite = loadUtilsPackage.createRootSuite
|
|
1800
|
+
|
|
1801
|
+
async function newCreateRootSuite () {
|
|
1802
|
+
return processRootSuite(await oldCreateRootSuite.apply(this, arguments))
|
|
1064
1803
|
}
|
|
1065
1804
|
|
|
1066
1805
|
// We need to proxy the createRootSuite function because the function is not configurable
|
|
1067
|
-
|
|
1806
|
+
return new Proxy(loadUtilsPackage, {
|
|
1068
1807
|
get (target, prop) {
|
|
1069
1808
|
if (prop === 'createRootSuite') {
|
|
1070
1809
|
return newCreateRootSuite
|
|
@@ -1072,32 +1811,52 @@ addHook({
|
|
|
1072
1811
|
return target[prop]
|
|
1073
1812
|
},
|
|
1074
1813
|
})
|
|
1075
|
-
|
|
1076
|
-
return proxy
|
|
1077
1814
|
})
|
|
1078
1815
|
|
|
1816
|
+
function prepareProcessHostStartRunner (processHost) {
|
|
1817
|
+
processHost._extraEnv = {
|
|
1818
|
+
...processHost._extraEnv,
|
|
1819
|
+
// Used to detect that we're in a playwright worker
|
|
1820
|
+
DD_PLAYWRIGHT_WORKER: '1',
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
function finishProcessHostStartRunner (processHost) {
|
|
1825
|
+
if (!processHost.process) {
|
|
1826
|
+
return
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
// We add a new listener to `processHost.process`, which represents the worker
|
|
1830
|
+
processHost.process.on('message', (message) => {
|
|
1831
|
+
if (message?.type === EFD_RETRY_COUNT_REQUEST) {
|
|
1832
|
+
sendEfdRetryCountToWorkerWhenAvailable(processHost.process, message.testId)
|
|
1833
|
+
return
|
|
1834
|
+
}
|
|
1835
|
+
if (message?.type === DD_PROPERTIES_REQUEST) {
|
|
1836
|
+
sendDdPropertiesToWorkerWhenAvailable(processHost.process, message.testId)
|
|
1837
|
+
return
|
|
1838
|
+
}
|
|
1839
|
+
// These messages are [code, payload]. The payload is test data
|
|
1840
|
+
if (Array.isArray(message) && message[0] === PLAYWRIGHT_WORKER_TRACE_PAYLOAD_CODE) {
|
|
1841
|
+
workerReportCh.publish({
|
|
1842
|
+
serializedTraces: message[1],
|
|
1843
|
+
screenshots: processHost[kDdPlaywrightFailureScreenshots]?.shift(),
|
|
1844
|
+
})
|
|
1845
|
+
}
|
|
1846
|
+
})
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1079
1849
|
// main process hook
|
|
1080
1850
|
addHook({
|
|
1081
1851
|
name: 'playwright',
|
|
1082
1852
|
file: 'lib/runner/processHost.js',
|
|
1083
|
-
versions: ['>=1.38.0'],
|
|
1853
|
+
versions: ['>=1.38.0 <1.60.0'],
|
|
1084
1854
|
}, (processHostPackage) => {
|
|
1085
1855
|
shimmer.wrap(processHostPackage.ProcessHost.prototype, 'startRunner', startRunner => async function () {
|
|
1086
|
-
this
|
|
1087
|
-
...this._extraEnv,
|
|
1088
|
-
// Used to detect that we're in a playwright worker
|
|
1089
|
-
DD_PLAYWRIGHT_WORKER: '1',
|
|
1090
|
-
}
|
|
1856
|
+
prepareProcessHostStartRunner(this)
|
|
1091
1857
|
|
|
1092
1858
|
const res = await startRunner.apply(this, arguments)
|
|
1093
|
-
|
|
1094
|
-
// We add a new listener to `this.process`, which is represents the worker
|
|
1095
|
-
this.process.on('message', (message) => {
|
|
1096
|
-
// These messages are [code, payload]. The payload is test data
|
|
1097
|
-
if (Array.isArray(message) && message[0] === PLAYWRIGHT_WORKER_TRACE_PAYLOAD_CODE) {
|
|
1098
|
-
workerReportCh.publish(message[1])
|
|
1099
|
-
}
|
|
1100
|
-
})
|
|
1859
|
+
finishProcessHostStartRunner(this)
|
|
1101
1860
|
|
|
1102
1861
|
return res
|
|
1103
1862
|
})
|
|
@@ -1105,43 +1864,77 @@ addHook({
|
|
|
1105
1864
|
return processHostPackage
|
|
1106
1865
|
})
|
|
1107
1866
|
|
|
1867
|
+
async function handlePageGoto (page) {
|
|
1868
|
+
if (!testPageGotoCh.hasSubscribers || !page || typeof page.evaluate !== 'function') {
|
|
1869
|
+
return
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
let rumState
|
|
1873
|
+
try {
|
|
1874
|
+
rumState = await page.evaluate(detectRum)
|
|
1875
|
+
} catch (error) {
|
|
1876
|
+
// Redirects and closed contexts can make page evaluation fail after a successful navigation.
|
|
1877
|
+
log.error('Playwright RUM detection error', error)
|
|
1878
|
+
return
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
if (!rumState) {
|
|
1882
|
+
return
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
const { isRumInstrumented, isRumActive, rumSamplingRate } = rumState
|
|
1886
|
+
if (isRumInstrumented && rumSamplingRate < 100 && !isRumActive) {
|
|
1887
|
+
log.debug("RUM was detected on the page, but it isn't active because the sampling rate is below 100%")
|
|
1888
|
+
}
|
|
1889
|
+
if (!isRumActive) {
|
|
1890
|
+
return
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
let browserVersion
|
|
1894
|
+
try {
|
|
1895
|
+
browserVersion = page.context().browser()?.version()
|
|
1896
|
+
} catch (error) {
|
|
1897
|
+
log.error('Playwright browser metadata error', error)
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
const context = {
|
|
1901
|
+
isRumActive,
|
|
1902
|
+
browserVersion,
|
|
1903
|
+
testExecutionId: undefined,
|
|
1904
|
+
}
|
|
1905
|
+
try {
|
|
1906
|
+
testPageGotoCh.publish(context)
|
|
1907
|
+
} catch (error) {
|
|
1908
|
+
log.error('Playwright RUM correlation channel error', error)
|
|
1909
|
+
return
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
if (!context.testExecutionId) {
|
|
1913
|
+
return
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
try {
|
|
1917
|
+
const domain = new URL(page.url()).hostname
|
|
1918
|
+
await page.context().addCookies([{
|
|
1919
|
+
name: RUM_COOKIE_NAME,
|
|
1920
|
+
value: context.testExecutionId,
|
|
1921
|
+
domain,
|
|
1922
|
+
path: '/',
|
|
1923
|
+
}])
|
|
1924
|
+
} catch (error) {
|
|
1925
|
+
log.error('Playwright RUM correlation cookie error', error)
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1108
1929
|
addHook({
|
|
1109
1930
|
name: 'playwright-core',
|
|
1110
1931
|
file: 'lib/client/page.js',
|
|
1111
|
-
versions: ['>=1.38.0'],
|
|
1932
|
+
versions: ['>=1.38.0 <1.60.0'],
|
|
1112
1933
|
}, (pagePackage) => {
|
|
1113
1934
|
shimmer.wrap(pagePackage.Page.prototype, 'goto', goto => async function (url, options) {
|
|
1114
1935
|
const response = await goto.apply(this, arguments)
|
|
1115
1936
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
try {
|
|
1119
|
-
if (page) {
|
|
1120
|
-
const { isRumInstrumented, isRumActive, rumSamplingRate } = await page.evaluate(() => {
|
|
1121
|
-
const isRumInstrumented = !!window.DD_RUM
|
|
1122
|
-
const isRumActive = window.DD_RUM && window.DD_RUM.getInternalContext
|
|
1123
|
-
? !!window.DD_RUM.getInternalContext()
|
|
1124
|
-
: false
|
|
1125
|
-
const rumSamplingRate = window.DD_RUM && window.DD_RUM.getInitConfiguration
|
|
1126
|
-
? window.DD_RUM.getInitConfiguration().sessionSampleRate
|
|
1127
|
-
: null
|
|
1128
|
-
return { isRumInstrumented, isRumActive, rumSamplingRate }
|
|
1129
|
-
})
|
|
1130
|
-
if (isRumInstrumented && rumSamplingRate < 100 && !isRumActive) {
|
|
1131
|
-
log.debug("RUM was detected on the page, but it isn't active because the sampling rate is below 100%")
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
if (isRumActive) {
|
|
1135
|
-
testPageGotoCh.publish({
|
|
1136
|
-
isRumActive,
|
|
1137
|
-
page,
|
|
1138
|
-
})
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
} catch (e) {
|
|
1142
|
-
// ignore errors such as redirects, context destroyed, etc
|
|
1143
|
-
log.error('goto hook error', e)
|
|
1144
|
-
}
|
|
1937
|
+
await handlePageGoto(this)
|
|
1145
1938
|
|
|
1146
1939
|
return response
|
|
1147
1940
|
})
|
|
@@ -1149,20 +1942,38 @@ addHook({
|
|
|
1149
1942
|
return pagePackage
|
|
1150
1943
|
})
|
|
1151
1944
|
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1945
|
+
function instrumentWorkerMainMethods (workerMain) {
|
|
1946
|
+
if (!workerMain || workerMain[kDdPlaywrightWorkerInstrumented] ||
|
|
1947
|
+
typeof workerMain._runTest !== 'function' || typeof workerMain.dispatchEvent !== 'function') {
|
|
1948
|
+
return workerMain
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
Object.defineProperty(workerMain, kDdPlaywrightWorkerInstrumented, { value: true })
|
|
1952
|
+
|
|
1158
1953
|
// we assume there's only a test running at a time
|
|
1159
1954
|
let steps = []
|
|
1160
1955
|
const stepInfoByStepId = {}
|
|
1161
1956
|
|
|
1162
|
-
shimmer.wrap(
|
|
1957
|
+
shimmer.wrap(workerMain, 'runTestGroup', runTestGroup => function (runPayload) {
|
|
1958
|
+
const disabledIds = runPayload._ddDisabledTestIds
|
|
1959
|
+
this[kDdPlaywrightDisabledTestIds] = disabledIds ? new Set(disabledIds) : undefined
|
|
1960
|
+
return runTestGroup.apply(this, arguments)
|
|
1961
|
+
})
|
|
1962
|
+
|
|
1963
|
+
shimmer.wrap(workerMain, '_runTest', _runTest => async function (test) {
|
|
1964
|
+
if (this[kDdPlaywrightDisabledTestIds]?.has(test.id)) {
|
|
1965
|
+
test._ddIsDisabled = true
|
|
1966
|
+
test.expectedStatus = 'skipped'
|
|
1967
|
+
}
|
|
1968
|
+
await waitForEfdRetryCount(test)
|
|
1969
|
+
if (shouldSkipEfdRetry(test)) {
|
|
1970
|
+
test._ddShouldSkipEfdRetry = true
|
|
1971
|
+
test.expectedStatus = 'skipped'
|
|
1972
|
+
}
|
|
1163
1973
|
if (test.expectedStatus === 'skipped') {
|
|
1164
1974
|
return _runTest.apply(this, arguments)
|
|
1165
1975
|
}
|
|
1976
|
+
test._ddStartTime = performance.now()
|
|
1166
1977
|
steps = []
|
|
1167
1978
|
|
|
1168
1979
|
const {
|
|
@@ -1189,6 +2000,27 @@ addHook({
|
|
|
1189
2000
|
browserName,
|
|
1190
2001
|
}
|
|
1191
2002
|
testToCtx.set(test, testCtx)
|
|
2003
|
+
|
|
2004
|
+
// Wait for ddProperties to be received and processed. The main process sends
|
|
2005
|
+
// this during Playwright's testEnd event, which can happen before _runTest
|
|
2006
|
+
// resolves in 1.60 when retry clones run across multiple workers.
|
|
2007
|
+
let hasDdProperties = false
|
|
2008
|
+
const ddPropertiesDeferred = {}
|
|
2009
|
+
const ddPropertiesPromise = new Promise(resolve => {
|
|
2010
|
+
ddPropertiesDeferred.resolve = resolve
|
|
2011
|
+
})
|
|
2012
|
+
const ddPropertiesMessageHandler = ({ type, testId, properties }) => {
|
|
2013
|
+
if (type === DD_PROPERTIES_RESPONSE && testId === test.id) {
|
|
2014
|
+
hasDdProperties = true
|
|
2015
|
+
if (properties) {
|
|
2016
|
+
Object.assign(test, properties)
|
|
2017
|
+
}
|
|
2018
|
+
process.removeListener('message', ddPropertiesMessageHandler)
|
|
2019
|
+
ddPropertiesDeferred.resolve()
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
process.on('message', ddPropertiesMessageHandler)
|
|
2023
|
+
|
|
1192
2024
|
// TODO - In the future we may need to implement a mechanism to send test properties
|
|
1193
2025
|
// to the worker process before _runTest is called
|
|
1194
2026
|
testStartCh.runStores(testCtx, () => {
|
|
@@ -1209,13 +2041,7 @@ addHook({
|
|
|
1209
2041
|
fn: async function ({ page }) {
|
|
1210
2042
|
try {
|
|
1211
2043
|
if (page) {
|
|
1212
|
-
const isRumActive = await page.evaluate(
|
|
1213
|
-
if (window.DD_RUM && window.DD_RUM.stopSession) {
|
|
1214
|
-
window.DD_RUM.stopSession()
|
|
1215
|
-
return true
|
|
1216
|
-
}
|
|
1217
|
-
return false
|
|
1218
|
-
})
|
|
2044
|
+
const isRumActive = await page.evaluate(stopRumSession)
|
|
1219
2045
|
|
|
1220
2046
|
if (isRumActive) {
|
|
1221
2047
|
// Give some time RUM to flush data, similar to what we do in selenium
|
|
@@ -1224,10 +2050,11 @@ addHook({
|
|
|
1224
2050
|
if (url) {
|
|
1225
2051
|
const domain = new URL(url).hostname
|
|
1226
2052
|
await page.context().addCookies([{
|
|
1227
|
-
name:
|
|
2053
|
+
name: RUM_COOKIE_NAME,
|
|
1228
2054
|
value: '',
|
|
1229
2055
|
domain,
|
|
1230
2056
|
path: '/',
|
|
2057
|
+
expires: 0,
|
|
1231
2058
|
}])
|
|
1232
2059
|
} else {
|
|
1233
2060
|
log.error('RUM is active but page.url() is not available')
|
|
@@ -1251,6 +2078,31 @@ addHook({
|
|
|
1251
2078
|
await res
|
|
1252
2079
|
|
|
1253
2080
|
const { status, error, annotations, retry, testId } = testInfo
|
|
2081
|
+
const testEfdKey = getTestEfdKey(test)
|
|
2082
|
+
const isEfdManagedTest = isTestEfdManaged(test)
|
|
2083
|
+
if (isEfdManagedTest && !test._ddIsEfdRetry && !efdRetryCountByTestKey.has(testEfdKey)) {
|
|
2084
|
+
const duration = test.results?.at(-1)?.duration > 0
|
|
2085
|
+
? test.results.at(-1).duration
|
|
2086
|
+
: performance.now() - test._ddStartTime
|
|
2087
|
+
const retryCount = getEfdRetryCount(
|
|
2088
|
+
duration,
|
|
2089
|
+
getTestEfdSlowTestRetries(test)
|
|
2090
|
+
)
|
|
2091
|
+
setEfdRetryCountForTest(test, retryCount)
|
|
2092
|
+
if (retryCount === 0) {
|
|
2093
|
+
efdSlowAbortedTests.add(testEfdKey)
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
if (!hasDdProperties && process.send) {
|
|
2098
|
+
process.send({
|
|
2099
|
+
type: DD_PROPERTIES_REQUEST,
|
|
2100
|
+
testId: test.id,
|
|
2101
|
+
})
|
|
2102
|
+
} else if (!hasDdProperties) {
|
|
2103
|
+
process.removeListener('message', ddPropertiesMessageHandler)
|
|
2104
|
+
ddPropertiesDeferred.resolve()
|
|
2105
|
+
}
|
|
1254
2106
|
|
|
1255
2107
|
// testInfo.errors could be better than "error",
|
|
1256
2108
|
// which will only include timeout error (even though the test failed because of a different error)
|
|
@@ -1266,26 +2118,30 @@ addHook({
|
|
|
1266
2118
|
onDone = resolve
|
|
1267
2119
|
})
|
|
1268
2120
|
|
|
1269
|
-
// Wait for
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
process.removeListener('message', messageHandler)
|
|
1279
|
-
resolve()
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
// Add the listener
|
|
1284
|
-
process.on('message', messageHandler)
|
|
2121
|
+
// Wait for the properties to be received, but do not block the worker forever if IPC fails.
|
|
2122
|
+
const ddPropertiesTimeoutPromise = new Promise(resolve => {
|
|
2123
|
+
const ddPropertiesTimeout = realSetTimeout(() => {
|
|
2124
|
+
process.removeListener('message', ddPropertiesMessageHandler)
|
|
2125
|
+
resolve()
|
|
2126
|
+
}, DD_PROPERTIES_TIMEOUT)
|
|
2127
|
+
ddPropertiesPromise.then(() => {
|
|
2128
|
+
realClearTimeout(ddPropertiesTimeout)
|
|
2129
|
+
})
|
|
1285
2130
|
})
|
|
2131
|
+
await Promise.race([ddPropertiesPromise, ddPropertiesTimeoutPromise])
|
|
1286
2132
|
|
|
1287
|
-
|
|
1288
|
-
|
|
2133
|
+
const finalStatus = getFinalStatus({
|
|
2134
|
+
isFinalExecution: test._ddIsFinalExecution,
|
|
2135
|
+
isDisabled: test._ddIsDisabled,
|
|
2136
|
+
isQuarantined: test._ddIsQuarantined,
|
|
2137
|
+
isAtrRetry: test._ddIsAtrRetry,
|
|
2138
|
+
isEfdManagedTest: test._ddIsEfdManagedTest,
|
|
2139
|
+
isAttemptToFix: test._ddIsAttemptToFix,
|
|
2140
|
+
hasFailedAllRetries: test._ddHasFailedAllRetries,
|
|
2141
|
+
hasFailedAttemptToFixRetries: test._ddHasFailedAttemptToFixRetries,
|
|
2142
|
+
hasPassedAnyEfdAttempt: test._ddHasPassedAnyEfdAttempt,
|
|
2143
|
+
testStatus: STATUS_TO_TEST_STATUS[status],
|
|
2144
|
+
})
|
|
1289
2145
|
|
|
1290
2146
|
testFinishCh.publish({
|
|
1291
2147
|
testStatus: STATUS_TO_TEST_STATUS[status],
|
|
@@ -1306,6 +2162,8 @@ addHook({
|
|
|
1306
2162
|
isAtrRetry: test._ddIsAtrRetry,
|
|
1307
2163
|
isModified: test._ddIsModified,
|
|
1308
2164
|
onDone,
|
|
2165
|
+
finalStatus,
|
|
2166
|
+
earlyFlakeAbortReason: test._ddEarlyFlakeAbortReason,
|
|
1309
2167
|
...testCtx.currentStore,
|
|
1310
2168
|
})
|
|
1311
2169
|
|
|
@@ -1316,8 +2174,10 @@ addHook({
|
|
|
1316
2174
|
|
|
1317
2175
|
// We reproduce what happens in `Dispatcher#_onStepBegin` and `Dispatcher#_onStepEnd`,
|
|
1318
2176
|
// since `startTime` and `duration` are not available directly in the worker process
|
|
1319
|
-
shimmer.wrap(
|
|
1320
|
-
if (event === '
|
|
2177
|
+
shimmer.wrap(workerMain, 'dispatchEvent', dispatchEvent => function (event, payload) {
|
|
2178
|
+
if (event === 'testBegin' || event === 'testEnd') {
|
|
2179
|
+
automaticFailureScreenshotPaths.clear()
|
|
2180
|
+
} else if (event === 'stepBegin') {
|
|
1321
2181
|
stepInfoByStepId[payload.stepId] = {
|
|
1322
2182
|
startTime: payload.wallTime,
|
|
1323
2183
|
title: payload.title,
|
|
@@ -1333,20 +2193,33 @@ addHook({
|
|
|
1333
2193
|
duration: payload.wallTime - stepInfo.startTime,
|
|
1334
2194
|
error: payload.error,
|
|
1335
2195
|
})
|
|
2196
|
+
} else if (event === 'attach' && isAutomaticFailureScreenshotAttachment(payload)) {
|
|
2197
|
+
payload._ddIsAutomaticFailureScreenshot = true
|
|
1336
2198
|
}
|
|
1337
2199
|
return dispatchEvent.apply(this, arguments)
|
|
1338
2200
|
})
|
|
1339
2201
|
|
|
2202
|
+
return workerMain
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
// Only in worker
|
|
2206
|
+
addHook({
|
|
2207
|
+
name: 'playwright',
|
|
2208
|
+
file: 'lib/worker/workerMain.js',
|
|
2209
|
+
versions: ['>=1.38.0 <1.60.0'],
|
|
2210
|
+
}, (workerPackage) => {
|
|
2211
|
+
instrumentWorkerMainMethods(workerPackage.WorkerMain.prototype)
|
|
1340
2212
|
return workerPackage
|
|
1341
2213
|
})
|
|
1342
2214
|
|
|
1343
2215
|
function generateSummaryWrapper (generateSummary) {
|
|
1344
|
-
return function () {
|
|
2216
|
+
return function (...args) {
|
|
1345
2217
|
for (const test of this.suite.allTests()) {
|
|
1346
2218
|
// https://github.com/microsoft/playwright/blob/bf92ffecff6f30a292b53430dbaee0207e0c61ad/packages/playwright/src/reporters/base.ts#L279
|
|
1347
|
-
const
|
|
1348
|
-
(!test.results.length || test.expectedStatus !== 'skipped')
|
|
1349
|
-
if (
|
|
2219
|
+
const shouldReportAsSkipped = test.outcome() === 'skipped' &&
|
|
2220
|
+
(disabledTestIds.has(test.id) || !test.results.length || test.expectedStatus !== 'skipped')
|
|
2221
|
+
if (shouldReportAsSkipped && !testsReportedInGenerateSummary.has(test)) {
|
|
2222
|
+
testsReportedInGenerateSummary.add(test)
|
|
1350
2223
|
const {
|
|
1351
2224
|
_requireFile: testSuiteAbsolutePath,
|
|
1352
2225
|
location: {
|
|
@@ -1373,7 +2246,7 @@ function generateSummaryWrapper (generateSummary) {
|
|
|
1373
2246
|
})
|
|
1374
2247
|
}
|
|
1375
2248
|
}
|
|
1376
|
-
return generateSummary.apply(this,
|
|
2249
|
+
return generateSummary.apply(this, args)
|
|
1377
2250
|
}
|
|
1378
2251
|
}
|
|
1379
2252
|
|
|
@@ -1384,7 +2257,7 @@ function generateSummaryWrapper (generateSummary) {
|
|
|
1384
2257
|
addHook({
|
|
1385
2258
|
name: 'playwright',
|
|
1386
2259
|
file: 'lib/reporters/base.js',
|
|
1387
|
-
versions: ['>=1.38.0'],
|
|
2260
|
+
versions: ['>=1.38.0 <1.60.0'],
|
|
1388
2261
|
}, (reportersPackage) => {
|
|
1389
2262
|
// v1.50.0 changed the name of the base reporter from BaseReporter to TerminalReporter
|
|
1390
2263
|
if (reportersPackage.TerminalReporter) {
|