fix(tests): windows pathing (#45799)
* fix: tests on Windows * fix: use path join insteadpull/45804/head
parent
6d2b211921
commit
d92eb803da
|
@ -24,7 +24,7 @@ describe('getProjectPath helper', () => {
|
|||
describe('getProjectName helper', () => {
|
||||
it('should return the last path segment of the calling dir', () => {
|
||||
const mockCallingDir = 'calling/dir';
|
||||
const expected = `dir`;
|
||||
const expected = 'dir';
|
||||
|
||||
// Add mock to test condition
|
||||
process.env.CALLING_DIR = mockCallingDir;
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import path from 'path';
|
||||
|
||||
export function getProjectPath(): string {
|
||||
return (process.env.CALLING_DIR || process.cwd()) + path.sep;
|
||||
return (process.env.CALLING_DIR || process.cwd()) + '/';
|
||||
}
|
||||
|
||||
export function getProjectName(): string {
|
||||
return getProjectPath().split(path.sep).slice(-2)[0];
|
||||
return getProjectPath().split('/').slice(-2)[0];
|
||||
}
|
||||
|
|
|
@ -69,12 +69,18 @@ describe('getMetaData helper', () => {
|
|||
it('should throw if file is not found', () => {
|
||||
process.env.CALLING_DIR =
|
||||
'curriculum/challenges/english/superblock/mick-priject';
|
||||
|
||||
const errorPath = path.join(
|
||||
'curriculum',
|
||||
'challenges',
|
||||
'_meta',
|
||||
'mick-priject',
|
||||
'meta.json'
|
||||
);
|
||||
expect(() => {
|
||||
getMetaData();
|
||||
}).toThrowError(
|
||||
new Error(
|
||||
`ENOENT: no such file or directory, open 'curriculum/challenges/_meta/mick-priject/meta.json'`
|
||||
)
|
||||
new Error(`ENOENT: no such file or directory, open '${errorPath}'`)
|
||||
);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue