Skip to content

Instantly share code, notes, and snippets.

@kozo002
Created December 22, 2016 09:10
Show Gist options
  • Save kozo002/7e080bc48a95ba18db37cc91baa54f64 to your computer and use it in GitHub Desktop.
Save kozo002/7e080bc48a95ba18db37cc91baa54f64 to your computer and use it in GitHub Desktop.
for jest on Rails
module.exports = {
_path(basePath, filePath) {
let splitDir = __dirname.split("/");
splitDir.shift();
let appRootIndex;
splitDir.map((dir, i) => {
if (dir === "spec") {
appRootIndex = i;
}
});
splitDir.splice(appRootIndex, splitDir.length - appRootIndex);
splitDir = splitDir.concat(basePath.split("/"))
splitDir = splitDir.concat(filePath.split("/"))
return "/" + splitDir.join("/");
},
appPath(filePath) {
return this._path("app/assets/javascripts", filePath);
},
supportPath(filePath) {
return this._path("spec/support/javascript", filePath);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment