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

fix(breaking-change): update for nodes 18 and 20 #170

Merged
merged 9 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [16]
node-version: [18]
os: [ubuntu-latest]

steps:
Expand All @@ -31,6 +31,6 @@ jobs:
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_TITLE: 'Node version'
SLACK_MESSAGE: ${{ matrix.node }}
SLACK_MESSAGE: ${{ matrix.node-version }}
SLACK_COLOR: ${{ job.status == 'success' && 'good' || job.status == 'cancelled' && '#808080' || 'danger' }}

2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [18.x, 20.x]
os: [ubuntu-latest, windows-latest]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-push-publish-to-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
node-version: 18
- run: npm install
- run: npm test
- uses: JS-DevTools/npm-publish@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
git config user.email github-actions@github.com
- uses: actions/setup-node@v1
with:
node-version: 16
node-version: 18
- run: |
npm install
npm test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/version-bump-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
git config user.email github-actions@github.com
- uses: actions/setup-node@v1
with:
node-version: 14
node-version: 18
- run: |
npm install
npm test
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
"jest": "^29",
"jest-fetch-mock": "^3.0.2",
"jest-junit": "^16.0.0",
"jest-plugin-fs": "^2.9.0",
"jsdoc": "^3.6.3",
"jsdoc-to-markdown": "^5.0.0",
"memfs": "^4.6.0",
"stdout-stderr": "^0.1.9",
"tsd-jsdoc": "^2.4.0",
"typescript": "^4.9.5"
},
"engines": {
"node": "^14.18 || ^16.13 || >=18"
"node": ">=18"
},
"scripts": {
"e2e": "jest --config e2e/jest.config.js --runInBand",
Expand Down
9 changes: 9 additions & 0 deletions test/__mocks__/fs-extra.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { fs } = require('memfs')

module.exports = {
...jest.requireActual('fs-extra'),
// fix for "TypeError: Class constructors cannot be invoked without 'new'" - fs-extra and memfs don't mix well
...fs,
// fix for "(node:35530) [fs-extra-WARN0003] Warning: fs.realpath.native is not a function. Is fs being monkey-patched?"
realpath: jest.requireActual('fs').realpath
}
7 changes: 7 additions & 0 deletions test/__mocks__/fs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { fs } = require('memfs')

module.exports = {
...fs,
// fix for "(node:35530) [fs-extra-WARN0003] Warning: fs.realpath.native is not a function. Is fs being monkey-patched?"
realpath: jest.requireActual('fs').realpath // get rid of warnings
}
2 changes: 2 additions & 0 deletions test/__mocks__/fs/promises.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const { fs } = require('memfs')
module.exports = fs.promises
42 changes: 20 additions & 22 deletions test/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,15 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const { stdout } = require('stdout-stderr')
const { stdout, stderr } = require('stdout-stderr')
const fs = jest.requireActual('fs')
const eol = require('eol')
const { vol } = require('memfs')

const fetch = require('jest-fetch-mock')
const fileSystem = require('jest-plugin-fs').default

// dont touch the real fs
const mockFs = require('jest-plugin-fs/mock')

// jest-plugin-fs/mock is too old, and has no updates
// ... fs.rmSync is only available in node >= 14.
jest.mock('fs', () => ({
...mockFs,
rmSync: jest.fn()
}))
jest.mock('fs')
jest.mock('fs/promises')

process.env.CI = true

Expand All @@ -34,8 +27,13 @@ jest.setTimeout(30000)
jest.setMock('node-fetch', fetch)

// trap console log
beforeEach(() => { stdout.start() })
afterEach(() => { stdout.stop() })
beforeEach(() => {
stdout.start()
stderr.start()
// change this if you need to see logs from stdout
stdout.print = false
})
afterEach(() => { stdout.stop(); stderr.stop() })

// helper for fixtures
global.fixtureFile = (output) => {
Expand All @@ -56,36 +54,36 @@ global.fixtureZip = (output) => {
global.fakeFileSystem = {
addJson: (json) => {
// add to existing
fileSystem.mock(json)
vol.fromJSON(json, '/')
},
addJsonFolder: (folderPath) => {
fileSystem.mock(getFilesRecursively(folderPath))
vol.fromJSON(getFilesRecursively(folderPath), '/')
},
removeKeys: (arr) => {
// remove from existing
const files = fileSystem.files()
const files = vol.toJSON()
for (const prop in files) {
if (arr.includes(prop)) {
delete files[prop]
}
}
fileSystem.restore()
fileSystem.mock(files)
vol.reset()
vol.fromJSON(files)
},
clear: () => {
// reset to empty
fileSystem.restore()
vol.reset()
},
reset: () => {
// reset file system
fileSystem.restore()
vol.reset()
},
files: () => {
return fileSystem.files()
return vol.toJSON()
}
}
// seed the fake filesystem
fakeFileSystem.reset()
vol.reset()

// fixture matcher
expect.extend({
Expand Down