Skip to content

Commit 49fc3fa

Browse files
committed
fix: resolve failing test
1 parent 2c28e77 commit 49fc3fa

File tree

5 files changed

+41
-24
lines changed

5 files changed

+41
-24
lines changed

.babelrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

babel.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
sourceType: 'module',
3+
presets: [
4+
[
5+
'@babel/preset-env',
6+
{
7+
targets: {
8+
node: 'current',
9+
esmodules: true,
10+
},
11+
},
12+
],
13+
],
14+
}
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
// This patch is run from post-install script and it is a temporary hack until a pending PR is merged
2-
// More details here:
2+
// More details here:
33
// https://github.com/vuejs/vue-apollo/issues/1011
4-
54
const fs = require('fs')
65
const path = require('path')
76

8-
const loadTrackingPath = path.resolve(
7+
const useQueryPath = path.resolve(
98
__dirname,
10-
'../node_modules/@vue/apollo-composable/dist/util/loadingTracking.js'
9+
'../node_modules/@vue/apollo-composable/dist/useQuery.js',
1110
)
1211

13-
fs.writeFileSync(
14-
loadTrackingPath,
15-
fs.readFileSync(loadTrackingPath, 'utf8').replace(/\.\$root/m, '.root')
12+
const vueApolloComposablePath = path.resolve(
13+
__dirname,
14+
'../node_modules/@vue/apollo-composable/dist/vue-apollo-composable.js',
1615
)
1716

18-
const useQueryPath = path.resolve(
19-
__dirname,
20-
'../node_modules/@vue/apollo-composable/dist/useQuery.js'
17+
fs.writeFileSync(
18+
useQueryPath,
19+
fs.readFileSync(useQueryPath, 'utf8').replace(/^onServerPrefetch, /mu, ''),
2120
)
2221

2322
fs.writeFileSync(
2423
useQueryPath,
2524
fs
2625
.readFileSync(useQueryPath, 'utf8')
27-
.replace(/(^.*onServerPrefetch)/m, '$1=()=>{}; $1')
28-
.replace(/(.* require\("vue"\);)/m, '')
29-
.replace(/^.*(nextTick)/m, 'vue_demi_1.$1')
30-
)
26+
.replace(/onServerPrefetch === null.*?\}\);/msu, ''),
27+
)
28+
29+
fs.writeFileSync(
30+
vueApolloComposablePath,
31+
fs
32+
.readFileSync(vueApolloComposablePath, 'utf8')
33+
.replace(/vue_demi_5.onServerPrefetch === null.*?\}\);/msu, ''),
34+
)

jest.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const config = require('kcd-scripts/jest')
44
module.exports = merge(config, {
55
testEnvironment: 'jsdom',
66
moduleFileExtensions: ['js', 'vue'],
7+
coverageProvider: 'v8',
78
coverageDirectory: './coverage',
89
collectCoverageFrom: ['**/src/**/*.js', '!**/src/__tests__/**'],
910
transform: {
@@ -12,8 +13,14 @@ module.exports = merge(config, {
1213
},
1314
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
1415
testPathIgnorePatterns: [
15-
'<rootDir>/node_modules',
16+
'/node_modules/',
1617
'<rootDir>/src/__tests__/components',
1718
'<rootDir>/src/__tests__/directives',
1819
],
20+
moduleNameMapper: {
21+
'@vue/apollo-composable': [
22+
'<rootDir>/node_modules/@vue/apollo-composable/dist/index.js',
23+
],
24+
},
25+
transformIgnorePatterns: ['node_modules/(?!(@vue/apollo-composable)/)'],
1926
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@testing-library/jest-dom": "^5.11.5",
5959
"@testing-library/user-event": "^12.4.0",
6060
"@types/estree": "0.0.45",
61-
"@vue/apollo-composable": "4.0.0-alpha.10",
61+
"@vue/apollo-composable": "^4.0.0-alpha.12",
6262
"@vue/compiler-sfc": "^3.0.4",
6363
"apollo-boost": "^0.4.9",
6464
"apollo-cache-inmemory": "^1.6.6",

0 commit comments

Comments
 (0)