Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Suggestion(s) #3

Closed
xml opened this issue May 3, 2016 · 2 comments
Closed

Testing Suggestion(s) #3

xml opened this issue May 3, 2016 · 2 comments

Comments

@xml
Copy link

xml commented May 3, 2016

To E2E test this, for basic developer confidence, one could just create a basic JS project that's built with webpack, and has test coverage. Then, just write some tests for that demo project, demonstrating that requires now enforce case-sensitivity. In my case, I had to add the plugin to plugins on not only my webpack.config.js but also to the webpack config in my karma.conf.js.

Then, I created a jasmine spec file similar to the following:

describe("Case-Sensitive Paths Plugin", () => {
  it('shouldn\'t interfere with correctly-spelled imports', () => {
    const demoImport1 = require('../src/utils/api');
    expect(demoImport1).toBeDefined();
  });

  it('should cause mistakes in filename case to fail import', () => {
    expect(() => {const demoImport2 = require('../src/utils/API');}).toThrow();
  });

  it('should cause mistakes in path case to fail import', () => {
    expect(() => {const demoImport3 = require('../src/Utils/api');}).toThrow();
  });
});

Then I just run my standard unit-tests for the project. If the plugin is active, the last two tests pass, and if I disable it, they fail.

This is by no means an elegant solution that'll help you with ongoing development. But it gives me as an end-user some confidence that the plugin does what it says on the tin.

@xml
Copy link
Author

xml commented May 3, 2016

OK. I actually put my time where my mouth is and submitted a PR to do this. :-)

#4

@Urthen
Copy link
Owner

Urthen commented May 9, 2016

Closed in #4, thanks for the addition!

@Urthen Urthen closed this as completed May 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants