Skip to content

Commit

Permalink
Fix options.context being not extensible
Browse files Browse the repository at this point in the history
Fixes #1077
  • Loading branch information
szmarczak committed Sep 2, 2022
1 parent 231f55d commit b671480
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion source/core/options.ts
Expand Up @@ -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);
}
}
12 changes: 12 additions & 0 deletions test/arguments.ts
Expand Up @@ -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);

Expand Down

0 comments on commit b671480

Please sign in to comment.