forked from roxiness/routify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.thcrc.js
69 lines (60 loc) · 1.9 KB
/
.thcrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import * as path from 'path'
import * as fs from 'fs'
const testDir = 'test/e2e'
// ensures that we always use svelte from example/node_modules
const resolveSvelte = ({ appPath }) => {
if (appPath) {
const possibleLocations = [
() => path.resolve(fs.realpathSync(appPath), 'node_modules', 'svelte'),
() =>
path.resolve(
fs.realpathSync(__dirname),
'..',
'node_modules',
'svelte'
),
]
const found = possibleLocations.some(getPath => {
try {
const sveltePath = getPath()
if (fs.existsSync(sveltePath)) {
const { version } = require(path.join(sveltePath, 'package.json'))
process.env.SVELTE = sveltePath
// eslint-disable-next-line no-console
console.log(`[.thcrc] Use Svelte v${version}: ${sveltePath}`)
return true
}
} catch (err) {
if (err.code !== 'ENOENT') {
throw err
}
}
})
if (!found) {
const call = fn => fn()
// eslint-disable-next-line no-console
console.warn(
'Failed to find Svelte install. Tried locations:\n' +
possibleLocations
.map(call)
.map(loc => '- ' + loc)
.join('\n')
)
}
}
}
export default {
files: `./${testDir}/**/*.spec.js`,
bootstrap: resolveSvelte,
app: 'example',
// if the pages folder gets deleted, then our file watcher (for pages regen)
// will stop working
resetGlob: ['*', '!pages', 'pages/*'],
fixturesDir: path.resolve(__dirname, testDir, 'fixtures'),
// use FS (instead of RAM mock, that doesn't work currently with Routify)
fs: true,
// Puppeteer's Chromium's user data dir -- useful to remember settings,
// position, etc. of test browser (NOTE comment out & commit if not working
// in Windows -- I'll add some support for local ignored config one day)
userDataDir: '~/.svhs-pptr',
}