Skip to content

Commit

Permalink
mock moduleExists now that we've mocked css-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Judahmeek committed Aug 29, 2024
1 parent 624c63b commit 9594c96
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 4 deletions.
9 changes: 9 additions & 0 deletions test/package/development.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ const { chdirTestApp, resetEnv } = require("../helpers")
const rootPath = process.cwd()
chdirTestApp()

jest.mock("../../../package/utils/helpers", () => {
const original = jest.requireActual("../../../package/utils/helpers")
const moduleExists = () => false
return {
...original,
moduleExists,

Check failure on line 12 in test/package/development.test.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
}
})

describe("Development environment", () => {
beforeEach(() => jest.resetModules() && resetEnv())
afterAll(() => process.chdir(rootPath))
Expand Down
9 changes: 9 additions & 0 deletions test/package/environments/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ chdirTestApp()
const baseConfig = require("../../../package/environments/base")
const config = require("../../../package/config")

jest.mock("../../../package/utils/helpers", () => {
const original = jest.requireActual("../../../package/utils/helpers")
const moduleExists = () => false
return {
...original,
moduleExists,

Check failure on line 18 in test/package/environments/base.test.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
}
})

describe("Base config", () => {
beforeEach(() => jest.resetModules() && resetEnv())
afterAll(() => process.chdir(rootPath))
Expand Down
9 changes: 9 additions & 0 deletions test/package/environments/development.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ const { chdirTestApp, resetEnv } = require("../../helpers")
const rootPath = process.cwd()
chdirTestApp()

jest.mock("../../../package/utils/helpers", () => {
const original = jest.requireActual("../../../package/utils/helpers")
const moduleExists = () => false
return {
...original,
moduleExists,

Check failure on line 11 in test/package/environments/development.test.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
}
})

describe("Development specific config", () => {
beforeEach(() => {
jest.resetModules()
Expand Down
9 changes: 9 additions & 0 deletions test/package/environments/production.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ const { chdirTestApp, resetEnv } = require("../../helpers")
const rootPath = process.cwd()
chdirTestApp()

jest.mock("../../../package/utils/helpers", () => {
const original = jest.requireActual("../../../package/utils/helpers")
const moduleExists = () => false
return {
...original,
moduleExists,

Check failure on line 11 in test/package/environments/production.test.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
}
})

describe("Production specific config", () => {
beforeEach(() => {
jest.resetModules()
Expand Down
9 changes: 9 additions & 0 deletions test/package/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
const index = require("../../package/index")

jest.mock("../../../package/utils/helpers", () => {
const original = jest.requireActual("../../../package/utils/helpers")
const moduleExists = () => false
return {
...original,
moduleExists,

Check failure on line 8 in test/package/index.test.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
}
})

describe("index", () => {
test("exports webpack-merge v5 functions", () => {
expect(index.merge).toBeInstanceOf(Function)
Expand Down
9 changes: 9 additions & 0 deletions test/package/production.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ const { chdirTestApp } = require("../helpers")
const rootPath = process.cwd()
chdirTestApp()

jest.mock("../../../package/utils/helpers", () => {
const original = jest.requireActual("../../../package/utils/helpers")
const moduleExists = () => false
return {
...original,
moduleExists,

Check failure on line 12 in test/package/production.test.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
}
})

describe("Production environment", () => {
afterAll(() => process.chdir(rootPath))

Expand Down
9 changes: 9 additions & 0 deletions test/package/rules/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
const rules = require("../../../package/rules/index")

jest.mock("../../../package/utils/helpers", () => {
const original = jest.requireActual("../../../package/utils/helpers")
const moduleExists = () => false
return {
...original,
moduleExists,

Check failure on line 8 in test/package/rules/index.test.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
}
})

describe("index", () => {
test("rule tests are regexes", () => {
rules.forEach((rule) => expect(rule.test instanceof RegExp).toBe(true))
Expand Down
2 changes: 0 additions & 2 deletions test/package/rules/sass.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ jest.mock("../../../package/utils/helpers", () => {
const canProcess = (rule, fn) => {
return fn("This path was mocked")
}
const moduleExists = () => true
const packageMajorVersion = () => "15"
return {
...original,
canProcess,
moduleExists,
packageMajorVersion
}
})
Expand Down
2 changes: 0 additions & 2 deletions test/package/rules/sass1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ jest.mock("../../../package/utils/helpers", () => {
const canProcess = (rule, fn) => {
return fn("This path was mocked")
}
const moduleExists = () => true
return {
...original,
canProcess,

Check failure on line 10 in test/package/rules/sass1.test.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
moduleExists
}
})

Expand Down
9 changes: 9 additions & 0 deletions test/package/staging.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ const { chdirTestApp } = require("../helpers")
const rootPath = process.cwd()
chdirTestApp()

jest.mock("../../../package/utils/helpers", () => {
const original = jest.requireActual("../../../package/utils/helpers")
const moduleExists = () => false
return {
...original,
moduleExists,

Check failure on line 12 in test/package/staging.test.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
}
})

describe("Custom environment", () => {
afterAll(() => process.chdir(rootPath))

Expand Down
9 changes: 9 additions & 0 deletions test/package/test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ const { chdirTestApp } = require("../helpers")
const rootPath = process.cwd()
chdirTestApp()

jest.mock("../../../package/utils/helpers", () => {
const original = jest.requireActual("../../../package/utils/helpers")
const moduleExists = () => false
return {
...original,
moduleExists,

Check failure on line 12 in test/package/test.test.js

View workflow job for this annotation

GitHub Actions / Linting

Delete `,`
}
})

describe("Test environment", () => {
afterAll(() => process.chdir(rootPath))

Expand Down

0 comments on commit 9594c96

Please sign in to comment.