I need to write test cases for css file so whether css file present or not on specific folder or path..So how to check using karma or jasmine test cases. Need help... Thanks in advance..
Asked
Active
Viewed 550 times
2 Answers
0
You could implement basic node js inside the jasmine test case
var fs = require('fs');
if (fs.existsSync(path)) {
// Do something
}

Rohit Pothuraju
- 83
- 6
0
You can use this npm package: file-exists to check if filepath exists and is a file.

tanmay
- 7,761
- 2
- 19
- 38

Stanislav Kvitash
- 4,614
- 18
- 29
-
`describe('Testing CSS File Present or Not', function() { it('should be present or not', function(){ const fileExists = require('file-exists'); fileExists('../../source/css/solutionbuilder.css', (err, exists) => console.log(exists)) //console.log(fileExists.sync('../../source/css/solutionbuilder.css')) // expect(fileExists.sync('../../source/css/solutionbuilder.css')).toEqual('True'); }); });` I wrote above test cases code but it will throw 'require' is not define.Please help me @Stanislav Kvitash in that – Mahesh Sandhanshiv Jun 07 '17 at 12:08
-
Take a look at the answers here: [jasmine tests in karma: Uncaught ReferenceError: require is not defined](https://stackoverflow.com/questions/19117092/jasmine-tests-in-karma-uncaught-referenceerror-require-is-not-defined) – Stanislav Kvitash Jun 07 '17 at 12:52