Shopify / quilt

[⚠️ Deprecated] A loosely related set of packages for JavaScript/TypeScript projects at Shopify
MIT License
1.7k stars 222 forks source link

jest-koa-mocks: allow configuring subdomainOffset on koa's app instance #664

Closed falkenhawk closed 5 years ago

falkenhawk commented 5 years ago

Overview

Please allow passing subdomainOffset which would then be set on the koa app's instance inside createContext function. Maybe customProperties could be used for that. This is necessary to control how ctx.subdomains array is constructed from requested url. https://koajs.com/#settings

Type

Motivation

What inspired this feature request? What problems were you facing, or what else makes you think this should be in quilt?

I think that's the only thing which is missing to fully mock the koa's context object.

falkenhawk commented 5 years ago

it just struck me I can still configure it after creating the mock...:

      const ctx = createMockContext({ url, headers });
      ctx.app.subdomainOffset = subdomainOffset;
      console.log(ctx.subdomains); // now resolved with passed subdomainOffset