Skip to content

Commit

Permalink
Test on Node.js 8 (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Nov 10, 2020
1 parent a4d17c0 commit ecf20d2
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -48,3 +48,29 @@ jobs:
if: ${{ matrix.coverage }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
test-legacy:
name: Test - ubuntu-latest - Node v8.9, Webpack 4
runs-on: ubuntu-latest
env:
YARN_NODE_LINKER: node-modules
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Install dependencies
run: yarn
- name: Install webpack 4
run: yarn add -D webpack@4
- name: Build babel-loader
run: yarn run build
env:
BABEL_ENV: test
- name: Use Node.js 8.9
uses: actions/setup-node@v1
with:
node-version: '8.9'
- name: Run tests for webpack version 4
run: node scripts/test-legacy

1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,3 +8,4 @@ test/output
!.yarn/releases
.pnp.*
.vscode
scripts/test-legacy-source/output
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -7,7 +7,7 @@
],
"main": "lib/index.js",
"engines": {
"node": ">= 6.9"
"node": ">= 8.9"
},
"dependencies": {
"find-cache-dir": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions scripts/test-legacy-source/input.js
@@ -0,0 +1 @@
class App {}
52 changes: 52 additions & 0 deletions scripts/test-legacy.js
@@ -0,0 +1,52 @@
const webpack = require("webpack");
const path = require("path");
const fs = require("fs");
const assert = require("assert");

const babelLoader = path.join(__dirname, "../lib");

const config = {
mode: "development",
entry: path.join(__dirname, "test-legacy-source/input.js"),
output: {
path: path.join(__dirname, "test-legacy-source/output"),
},
module: {
rules: [
{
test: /\.jsx?/,
loader: babelLoader,
options: {
presets: ["@babel/preset-env"],
},
exclude: /node_modules/,
},
],
},
};

webpack(config, (err, stats) => {
assert.strictEqual(err, null);
assert.deepStrictEqual(stats.compilation.errors, []);
assert.deepStrictEqual(stats.compilation.warnings, []);

fs.readdir(path.join(__dirname, "test-legacy-source/output"), (err, files) => {
assert.strictEqual(err, null);
assert.strictEqual(files.length, 1);
fs.readFile(path.join(__dirname, "test-legacy-source/output", files[0]), (err, data) => {
assert.strictEqual(err, null);
const test = "var App = function App()";
const subject = data.toString();

assert.notStrictEqual(subject.indexOf(test), -1);

console.log("DONE");
clearTimeout(timeout);
});
});
});

const timeout = setTimeout(() => {
console.error("TIMEOUT");
process.exit(1);
}, 10 * 1000);

0 comments on commit ecf20d2

Please sign in to comment.