Skip to content

Commit

Permalink
package updates & technical debt cleanup (#1771)
Browse files Browse the repository at this point in the history
* package updates

* bump Next.js

* update for Next.js v13 new `Link` behavior

* see https://nextjs.org/docs/upgrading#link-component

* test tweaks, simplify getNetworkDisplayName()

* modify codeclimate excludes

* test tweaks and cleanup

* more cleanup

* switch to Node.js v18

* back to Node.js v16

* temporarily run CI against Node.js v16 & v18

* update codeowners

* fixtures fixes for asset price

* switch to Node.js v18

* package updates

* remark updates, typescript and test fixes

* fix

* test run fixes

* yet another lockfileVersion update

* package updates

* test run fixes
  • Loading branch information
kremalicious authored Dec 1, 2022
1 parent b58cb36 commit 1b612e4
Show file tree
Hide file tree
Showing 68 changed files with 51,393 additions and 4,527 deletions.
4 changes: 2 additions & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ exclude_patterns:
- '**/*.d.ts'
- '**/@types/'
- '**/_types.*'
- '**/*.stories.tsx'
- '**/*.test.tsx'
- '**/*.stories.*'
- '**/*.test.*'
- '.storybook/'
- '.jest/'
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @mihaisc @kremalicious @claudiaHash @bogdanfazakas @EnzoVezzaro
* @jamiehewitt15 @mihaisc @kremalicious @bogdanfazakas @EnzoVezzaro
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- v4
- v3
tags:
- '**'
Expand All @@ -20,7 +19,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: ['16']
node: ['18']

steps:
- uses: actions/checkout@v3
Expand All @@ -47,7 +46,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: ['16']
node: ['18']

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -82,7 +81,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
- name: Cache node_modules
uses: actions/cache@v3
env:
Expand Down Expand Up @@ -110,7 +109,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: ['16']
node: ['18']

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ coverage
.next
.artifacts
.vercel
.swc
repo-metadata.json
networks-metadata.json
src/@types/subgraph
Expand Down
2 changes: 1 addition & 1 deletion .jest/__fixtures__/assetsWithAccessDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1574,4 +1574,4 @@ export const assets: AssetExtended[] = [
validOrderTx: null
}
}
]
]
File renamed without changes.
3 changes: 3 additions & 0 deletions .jest/__mocks__/tar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// mocked, as this module makes Jest go all
// "Uncaught SyntaxError: Octal escape sequences are not allowed in strict mode"
export default jest.fn().mockImplementation(() => 'hello')
29 changes: 23 additions & 6 deletions .jest/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const createJestConfig = nextJest({
const customJestConfig = {
rootDir: '../',
// Add more setup options before each test is run
setupFilesAfterEnv: ['<rootDir>/.jest/jest.setup.js'],
setupFilesAfterEnv: ['<rootDir>/.jest/jest.setup.tsx'],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ['node_modules', '<rootDir>/src'],
testEnvironment: 'jest-environment-jsdom',
testEnvironment: 'jsdom',
moduleNameMapper: {
'^.+\\.(svg)$': '<rootDir>/.jest/__mocks__/svgrMock.tsx',
// '^@/components/(.*)$': '<rootDir>/components/$1',
'@components/(.*)$': '<rootDir>/src/components/$1',
'@shared(.*)$': '<rootDir>/src/components/@shared/$1',
'@hooks/(.*)$': '<rootDir>/src/@hooks/$1',
'@context/(.*)$': '<rootDir>/src/@context/$1',
Expand All @@ -29,8 +29,25 @@ const customJestConfig = {
'!src/**/*.{stories,test}.{ts,tsx}',
'!src/@types/**/*.{ts,tsx}'
],
testPathIgnorePatterns: ['node_modules', '\\.cache', '.next', 'coverage']
// Add ignores so ESM packages are not transformed by Jest
// note: this does not work with Next.js, hence workaround further down
// see: https://github.com/vercel/next.js/issues/35634#issuecomment-1115250297
// transformIgnorePatterns: ['node_modules/(?!(uuid|remark)/)'],
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/.next/',
'<rootDir>/coverage'
]
}

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)
// https://github.com/vercel/next.js/issues/35634#issuecomment-1115250297
async function jestConfig() {
const nextJestConfig = await createJestConfig(customJestConfig)()

// Add ignores for specific ESM packages so they are transformed by Jest
// /node_modules/ is the first pattern
nextJestConfig.transformIgnorePatterns[0] = '/node_modules/(?!uuid|remark)/'
return nextJestConfig
}

module.exports = jestConfig
3 changes: 0 additions & 3 deletions .jest/jest.setup.js

This file was deleted.

20 changes: 20 additions & 0 deletions .jest/jest.setup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import '@testing-library/jest-dom/extend-expect'
import { jest } from '@jest/globals'
import './__mocks__/matchMedia'
import './__mocks__/hooksMocks'

jest.mock('next/router', () => ({
useRouter: jest.fn().mockImplementation(() => ({
route: '/',
pathname: '/'
}))
}))

// jest.mock('next/head', () => {
// return {
// __esModule: true,
// default: ({ children }: { children: Array<React.ReactElement> }) => {
// return <>{children}</>
// }
// }
// })
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export default function NetworkName(): ReactElement {
const { networkId, isTestnet } = useWeb3()
const { networksList } = useNetworkMetadata()
const networkData = getNetworkDataById(networksList, networkId)
const networkName = getNetworkDisplayName(networkData, networkId)
const networkName = getNetworkDisplayName(networkData)

return (
<>
Expand Down
Loading

0 comments on commit 1b612e4

Please sign in to comment.