Skip to content

Commit

Permalink
Testing improvements.
Browse files Browse the repository at this point in the history
* Fix badges.

* Fix tests.

* Support multi-platform testing.

* Fix intermittent test failure. Don't support Node versions no longer in maintenance.
  • Loading branch information
Urthen authored Feb 1, 2018
1 parent 6f2519b commit 2abbfce
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
12 changes: 9 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ language: node_js
node_js:
- "node"
- "8"
- "7"
- "6"
- "5"
- "4"
- "4"

os:
- linux
- osx

branches:
only:
- master
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ Case Sensitive Paths - Webpack Plugin

[![Build Status](https://travis-ci.org/Urthen/case-sensitive-paths-webpack-plugin.svg?branch=master)](https://travis-ci.org/Urthen/case-sensitive-paths-webpack-plugin)
[![Known Vulnerabilities](https://snyk.io/test/github/urthen/case-sensitive-paths-webpack-plugin/badge.svg?targetFile=package.json)](https://snyk.io/test/github/urthen/case-sensitive-paths-webpack-plugin?targetFile=package.json)
[![npm](https://img.shields.io/npm/dm/localeval.svg)](https://www.npmjs.com/package/case-sensitive-paths-webpack-plugin)
![Bananas: Ripe](https://img.shields.io/badge/Bananas-Ripe-yellow.svg)
[![npm version](https://badge.fury.io/js/case-sensitive-paths-webpack-plugin.svg)](https://badge.fury.io/js/case-sensitive-paths-webpack-plugin)
[![npm downloads](https://img.shields.io/npm/dw/case-sensitive-paths-webpack-plugin.svg)](https://www.npmjs.com/package/case-sensitive-paths-webpack-plugin)
![bananas: ripe](https://img.shields.io/badge/bananas-ripe-yellow.svg)

This Webpack plugin enforces the entire path of all required modules match the exact case of the actual path on disk.
Using this plugin helps alleviate cases where developers working on OSX, which does not follow strict path case sensitivity,
Expand Down
41 changes: 27 additions & 14 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

const isPlatformCaseInsensitive = /^[win|darwin]/.test(process.platform);

let assert = require("assert");
let fs = require("fs-extra");
let path = require("path");
Expand All @@ -25,25 +27,29 @@ function webpackCompilerAtDir(dir, otherOpts) {

describe("CaseSensitivePathsPlugin", function() {

it("should compile and warn on wrong filename case", function(done) {
// This test will fail on case sensitive platforms, that's the whole point of this module.
// To ensure the rest of the library still works, disable *only this test.*
if (isPlatformCaseInsensitive) {
it("should compile and warn on wrong filename case", function (done) {
let compiler = webpackCompilerAtDir('wrong-case');

compiler.run(function(err, stats) {
if (err) done(err);
assert(stats.hasErrors());
assert.equal(stats.hasWarnings(), false);
let jsonStats = stats.toJson();
assert.equal(jsonStats.errors.length, 1);
compiler.run(function (err, stats) {
if (err) done(err);
assert(stats.hasErrors());
assert.equal(stats.hasWarnings(), false);
let jsonStats = stats.toJson();
assert.equal(jsonStats.errors.length, 1);

let error = jsonStats.errors[0];
// check that the plugin produces the correct output
assert(error.indexOf('[CaseSensitivePathsPlugin]') > -1);
assert(error.indexOf('ExistingTestFile.js') > -1); // wrong file require
assert(error.indexOf('existingTestFile.js') > -1); // actual file name
let error = jsonStats.errors[0];
// check that the plugin produces the correct output
assert(error.indexOf('[CaseSensitivePathsPlugin]') > -1);
assert(error.indexOf('ExistingTestFile.js') > -1); // wrong file require
assert(error.indexOf('existingTestFile.js') > -1); // actual file name

done();
done();
});
});
});
}

// For future reference: This test is somewhat of a race condition, these values seem to work well.
// If this test fails, sometimes just re-running will make it succeed.
Expand All @@ -61,6 +67,13 @@ describe("CaseSensitivePathsPlugin", function() {
let jsonStats;
let watcher = compiler.watch({poll: 500, aggregateTimeout: 500}, function(err, stats) {

// We already detected the change and marked ourselves done, don't continue.
// Short circuits some intermittent test errors where this would be called again after
// test completion.
if (resolved) {
return;
}

if (err) done(err);
watchCount++;

Expand Down

0 comments on commit 2abbfce

Please sign in to comment.