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

[FEAT] sync typescript versions #1613

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"chai": "4.3.6",
"react": "17",
"sinon": "10.0.0",
"typescript": "4.3.2",
"typescript": "5.0.4",
"validate-commit-msg": "2.14.0"
},
"config": {
Expand Down
7 changes: 3 additions & 4 deletions packages/sui-mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
"name": "@s-ui/mock",
"version": "1.2.0",
"main": "lib/index.js",
"description": "mock provider",
"types": "lib/index",
"description": "Mock provider",
"scripts": {
"lib": "babel --presets sui ./src --out-dir ./lib",
"prepublishOnly": "npm run lib",
"test": "npm run test:client && npm run test:server",
"test": "npm run test:browser && npm run test:server",
"test:browser": "npx @s-ui/test browser -P './test/browser/**/*Spec.js'",
"test:browser:watch": "npm run test:client -- --watch",
"test:server": "npx @s-ui/test server -P './test/server/**/*Spec.js'",
Expand All @@ -17,7 +16,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"msw": "0.47.4"
"msw": "1.2.1"
},
"repository": {
"type": "git",
Expand Down
11 changes: 8 additions & 3 deletions packages/sui-mock/src/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ export const getBrowserMocker = async (handlers = []) => {
const worker = setup(...handlers)

return {
...worker,
listen: worker.start,
close: worker.stop
start: worker.start.bind(worker),
stop: worker.stop.bind(worker),
listen: worker.start.bind(worker),
close: worker.stop.bind(worker),
use: worker.use.bind(worker),
resetHandlers: worker.resetHandlers.bind(worker),
restoreHandlers: worker.restoreHandlers.bind(worker),
printHandlers: worker.printHandlers.bind(worker)
}
}
2 changes: 1 addition & 1 deletion packages/sui-mock/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const isNode =

const setupMocker = isNode ? getServerMocker : getBrowserMocker

export {setupMocker, rest}
export {rest, setupMocker}
13 changes: 9 additions & 4 deletions packages/sui-mock/src/server.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
export {rest} from 'msw'

export const getServerMocker = async (handlers = []) => {
const {setupServer} = require('msw/node')
const setupServer = await import('msw/node').then(pkg => pkg.setupServer)
const worker = setupServer(...handlers)

return {
...worker,
start: worker.listen,
stop: worker.close
start: worker.listen.bind(worker),
stop: worker.close.bind(worker),
listen: worker.listen.bind(worker),
close: worker.close.bind(worker),
use: worker.use.bind(worker),
resetHandlers: worker.resetHandlers.bind(worker),
restoreHandlers: worker.restoreHandlers.bind(worker),
printHandlers: worker.printHandlers.bind(worker)
}
}
4 changes: 2 additions & 2 deletions packages/sui-test-contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
},
"dependencies": {
"@pact-foundation/pact": "9.18.1",
"@pactflow/pact-msw-adapter": "1.2.1",
"@s-ui/mock": "1",
"@pactflow/pact-msw-adapter": "2.0.0",
"@s-ui/mock": "beta",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll change it when the new sui-mock version is released in the next master workflow execution.

"commander": "8.3.0",
"headers-polyfill": "3.1.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/sui-test-contract/src/setup/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {stringify} from 'qs'

import {writeData2File} from '@pactflow/pact-msw-adapter/dist/utils/utils.js'
import {createWriter} from '@pactflow/pact-msw-adapter/dist/utils/utils.js'

const flatEntries = (input, prefix = '') =>
Object.entries(input).flatMap(([key, value]) => {
Expand Down Expand Up @@ -61,7 +61,7 @@ export const writerFactory = providers => (path, data) => {
})

console.log(`Writing the Pact file "${path}"`) // eslint-disable-line
writeData2File(path, data)
createWriter()(path, data)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix for a breaking change introduced in v1.4.0: pactflow/pact-msw-adapter@6d45541

}

export const mapProviders = providers =>
Expand Down
3 changes: 2 additions & 1 deletion packages/sui-test-contract/test/server/setupSpec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {expect} from 'chai'

import {FetcherFactory} from '@s-ui/domain'
import {rest} from '@s-ui/mock'
import mock from '@s-ui/mock'

import {setupContractTests} from '../../src/index.js'
import {getContractFileData, removeContractFiles} from '../utils.js'

const {rest} = mock
const fetcher = FetcherFactory.httpFetcher({config: {}})
const consumer = 'test-consumer'
const fujiAppleResponse = {color: 'red', type: 'Fuji'}
Expand Down
Loading