Skip to content

Hot reloading does not reload all files #835

@brianlaframboise

Description

@brianlaframboise

(Created from #823)

While hot reloading will reload a changed file, it does not appear that changes are actually used. For example, a changed file in the paths/ directory will be reloaded. However, those changes have no effect until the _.context.ts file is reloaded as well.

Steps to reproduce

Setup

Have a file structure like so:

counterfact/
    paths/
        _mocks/
            my-custom-code.ts
        _.context.ts

In _.context.ts:

import { CustomClass } from './_mocks/my-custom-code';

console.log("_.context.ts loaded");
// Do stuff with CustomClass

In ./_mocks/my-custom-code:

console.log("Custom code loaded");

const value = "Some value that's used in generating a mock response";

class CustomClass {
  // Use value in here somehow as part of generating a response
}

export { CustomClass }

Trigger

  1. Run counterfact (ex: npx counterfact spec.openapi.yaml counterfact)
  2. Call counterfact api, see the "Some value..." in the HTTP response
  3. Modify the custom code string to be something else ("const value = "Changed!")
  4. Note that Custom code loaded is logged
  5. Make a request to counterfact. Note that the new value is not returned

However, if I trivially modify the _.context.ts file (touch it, add a comment, etc), I do see counterfact log the _.context.ts loaded message. If I then make a new HTTP request, I see the new value in the mock http response.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions