From b671480715dbbff908e9a385f5e714570c663cd7 Mon Sep 17 00:00:00 2001 From: Szymon Marczak <36894700+szmarczak@users.noreply.github.com> Date: Fri, 2 Sep 2022 18:46:07 +0200 Subject: [PATCH] Fix `options.context` being not extensible Fixes #1077 --- source/core/options.ts | 1 - test/arguments.ts | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/core/options.ts b/source/core/options.ts index f5bff81d9..ae321d408 100644 --- a/source/core/options.ts +++ b/source/core/options.ts @@ -2521,6 +2521,5 @@ export default class Options { Object.freeze(options.retry.errorCodes); Object.freeze(options.retry.methods); Object.freeze(options.retry.statusCodes); - Object.freeze(options.context); } } diff --git a/test/arguments.ts b/test/arguments.ts index 5de4fb54f..89c706a3d 100644 --- a/test/arguments.ts +++ b/test/arguments.ts @@ -328,6 +328,18 @@ test.failing('`context` option is enumerable', withServer, async (t, server, got }); }); +test('`context` option is never frozen', t => { + const client = got.extend({ + context: { + token: 'foobar', + }, + }); + + client.defaults.options.context.token = '1234'; + + t.is(client.defaults.options.context.token, '1234'); +}); + test('`context` option is accessible when using hooks', withServer, async (t, server) => { server.get('/', echoUrl);