Skip to content

Commit

Permalink
ci: refactor (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Sep 6, 2021
1 parent acf5722 commit e67af52
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/nodejs.yml
Expand Up @@ -90,13 +90,15 @@ jobs:

- name: Run tests for webpack version ${{ matrix.webpack-version }}
run: npm run test:coverage -- --ci
env:
EXPERIMENTAL_USE_IMPORT_MODULE: "false"

- name: Submit coverage data to codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

test2:
test-new-api:
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack latest, experimentalUseImportModule

strategy:
Expand Down
13 changes: 10 additions & 3 deletions test/TestCases.test.js
Expand Up @@ -9,6 +9,8 @@ import webpack from "webpack";

import Self from "../src/index";

import yn from "./helpers/yn";

function clearDirectory(dirPath) {
let files;

Expand Down Expand Up @@ -128,9 +130,12 @@ describe("TestCases", () => {
config.plugins.map((p) => {
if (p.constructor === Self) {
const { options } = p;
options.experimentalUseImportModule =
!!process.env.EXPERIMENTAL_USE_IMPORT_MODULE;

options.experimentalUseImportModule = yn(
process.env.EXPERIMENTAL_USE_IMPORT_MODULE
);
}

return p;
}),
},
Expand Down Expand Up @@ -192,7 +197,9 @@ describe("TestCases", () => {
const expectedDirectoryByVersion = path.join(
expectedDirectory,
`webpack-${webpack.version[0]}${
process.env.EXPERIMENTAL_USE_IMPORT_MODULE ? "-importModule" : ""
yn(process.env.EXPERIMENTAL_USE_IMPORT_MODULE)
? "-importModule"
: ""
}`
);

Expand Down
4 changes: 3 additions & 1 deletion test/cases/auxiliary-assets/test.filter.js
@@ -1 +1,3 @@
module.exports = () => !process.env.EXPERIMENTAL_USE_IMPORT_MODULE;
import yn from "../../helpers/yn";

module.exports = () => !yn(process.env.EXPERIMENTAL_USE_IMPORT_MODULE);
13 changes: 13 additions & 0 deletions test/helpers/yn.js
@@ -0,0 +1,13 @@
function yn(value, defaultValue = false) {
if (/^(?:y|yes|true|1|on)$/i.test(value)) {
return true;
}

if (/^(?:n|no|false|0|off)$/i.test(value)) {
return false;
}

return defaultValue;
}

module.exports = yn;

0 comments on commit e67af52

Please sign in to comment.