Skip to content

Commit 6d3aecc

Browse files
committed
adjust tests so cache dirs are cleared only before compilations to workaround EBUSY problems on Windows
1 parent d6959ed commit 6d3aecc

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

packages/gatsby/src/utils/parcel/__tests__/compile-gatsby-files.ts

+38-38
Original file line numberDiff line numberDiff line change
@@ -58,52 +58,52 @@ describe(`gatsby file compilation`, () => {
5858
})
5959

6060
describe(`compileGatsbyFiles`, () => {
61-
afterEach(async () => {
62-
for (const directory of [dir.js, dir.ts]) {
63-
await remove(`${directory}/.cache`)
64-
}
65-
})
66-
67-
it(`should not compile gatsby-config.js`, async () => {
68-
await compileGatsbyFiles(dir.js)
69-
70-
const isCompiled = await pathExists(
71-
`${dir.js}/.cache/compiled/gatsby-config.js`
72-
)
73-
expect(isCompiled).toEqual(false)
74-
})
75-
76-
it(`should compile gatsby-config.ts`, async () => {
77-
await compileGatsbyFiles(dir.ts)
61+
describe(`js files are not touched`, () => {
62+
beforeAll(async () => {
63+
await remove(`${dir.js}/.cache`)
64+
await compileGatsbyFiles(dir.js)
65+
})
7866

79-
const compiledGatsbyConfig = await readFile(
80-
`${dir.ts}/.cache/compiled/gatsby-config.js`,
81-
`utf-8`
82-
)
67+
it(`should not compile gatsby-config.js`, async () => {
68+
const isCompiled = await pathExists(
69+
`${dir.js}/.cache/compiled/gatsby-config.js`
70+
)
71+
expect(isCompiled).toEqual(false)
72+
})
8373

84-
expect(compiledGatsbyConfig).toContain(siteMetadata.title)
85-
expect(compiledGatsbyConfig).toContain(siteMetadata.siteUrl)
86-
expect(compiledGatsbyConfig).toContain(moreDataConfig.options.name)
74+
it(`should not compile gatsby-node.js`, async () => {
75+
const isCompiled = await pathExists(
76+
`${dir.js}/.cache/compiled/gatsby-node.js`
77+
)
78+
expect(isCompiled).toEqual(false)
79+
})
8780
})
8881

89-
it(`should not compile gatsby-node.js`, async () => {
90-
await compileGatsbyFiles(dir.js)
82+
describe(`ts files are compiled`, () => {
83+
beforeAll(async () => {
84+
await remove(`${dir.ts}/.cache`)
85+
await compileGatsbyFiles(dir.ts)
86+
})
9187

92-
const isCompiled = await pathExists(
93-
`${dir.js}/.cache/compiled/gatsby-node.js`
94-
)
95-
expect(isCompiled).toEqual(false)
96-
})
88+
it(`should compile gatsby-config.ts`, async () => {
89+
const compiledGatsbyConfig = await readFile(
90+
`${dir.ts}/.cache/compiled/gatsby-config.js`,
91+
`utf-8`
92+
)
9793

98-
it(`should compile gatsby-node.ts`, async () => {
99-
await compileGatsbyFiles(dir.ts)
94+
expect(compiledGatsbyConfig).toContain(siteMetadata.title)
95+
expect(compiledGatsbyConfig).toContain(siteMetadata.siteUrl)
96+
expect(compiledGatsbyConfig).toContain(moreDataConfig.options.name)
97+
})
10098

101-
const compiledGatsbyNode = await readFile(
102-
`${dir.ts}/.cache/compiled/gatsby-node.js`,
103-
`utf-8`
104-
)
99+
it(`should compile gatsby-node.ts`, async () => {
100+
const compiledGatsbyNode = await readFile(
101+
`${dir.ts}/.cache/compiled/gatsby-node.js`,
102+
`utf-8`
103+
)
105104

106-
expect(compiledGatsbyNode).toContain(`I am working!`)
105+
expect(compiledGatsbyNode).toContain(`I am working!`)
106+
})
107107
})
108108
})
109109
})

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -3660,7 +3660,7 @@
36603660
"@parcel/utils" "2.3.1"
36613661
nullthrows "^1.1.1"
36623662

3663-
"@parcel/source-map@2.0.2", "@parcel/source-map@^2.0.0":
3663+
"@parcel/source-map@^2.0.0":
36643664
version "2.0.2"
36653665
resolved "https://registry.yarnpkg.com/@parcel/source-map/-/source-map-2.0.2.tgz#9aa0b00518cee31d5634de6e9c924a5539b142c1"
36663666
integrity sha512-NnUrPYLpYB6qyx2v6bcRPn/gVigmGG6M6xL8wIg/i0dP1GLkuY1nf+Hqdf63FzPTqqT7K3k6eE5yHPQVMO5jcA==

0 commit comments

Comments
 (0)