Invalid Typescript File
See original GitHub issuewhen i run ngentest app.component.ts, i get:
Error. invalid typescript file. e.g., Usage $0 <tsFile> [options]
my ngentest.config.js file:
const fs = require('fs');
const path = require('path');
const klassTemplate = fs.readFileSync(path.join(__dirname, 'src', 'class', 'class.template.ts.ejs'), 'utf8');
const componentTemplate = fs.readFileSync(path.join(__dirname, 'src', 'component', 'component.template.ts.ejs'), 'utf8');
const directiveTemplate = fs.readFileSync(path.join(__dirname, 'src', 'directive', 'directive.template.ts.ejs'), 'utf8');
const injectableTemplate = fs.readFileSync(path.join(__dirname, 'src', 'injectable', 'injectable.template.ts.ejs'), 'utf8');
const pipeTemplate = fs.readFileSync(path.join(__dirname, 'src', 'pipe', 'pipe.template.ts.ejs'), 'utf8');
module.exports = {
framework: 'karma', // or 'jest'
templates: {
klass: klassTemplate, // ejs contents read from file
component: componentTemplate,
directive: directiveTemplate,
injectable: injectableTemplate,
pipe: pipeTemplate
},
// necessary directives used for a component test
directives: [
'oneviewPermitted'
],
// necessary pipes used for a component test
pipes: [
'translate', 'phoneNumber', 'safeHtml'
],
// when convert to JS, some codes need to be replaced to work
replacements: [ // some 3rd party module causes an error
{ from: 'require\\("html-custom-element"\\)', to: '{}'},
{ from: '^\\S+\\.define\\(.*\\);', to: ''} // some commands causes error
],
// when constructor param type is as following, create a mock class with this properties
// e.g. @Injectable() MockElementRef { nativeElement = {}; }
providerMocks: {
ElementRef: ['nativeElement = {};'],
Router: ['navigate() {};'],
Document: ['querySelector() {};'],
HttpClient: ['post() {};'],
TranslateService: ['translate() {};'],
EncryptionService: [],
},
// when ngentest runs with a directory, include only these files
includeMatch: [/(component|directive|pipe|service).ts/],
// when ngentest runs with a directory, exclude these files
excludeMatch: []
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Getting invalid typescript errors in valid TS code - Stack Overflow
I am having a create-react-app (v17.0.2) with typescript (v4.5.5). I am getting typescript errors even in valid TS code.
Read more >ae-wrong-input-file-type - API Extractor
Unlike some other tools, API Extractor does not process TypeScript source files directly. Instead, it is designed to analyze the .d.ts files that...
Read more >TypeScript errors and how to fix them
export function logSomething(error: unknown): void;. Alternatively, you can write your function implementation inside a source code file ( *.ts ). TS1192.
Read more >Documentation - Do's and Don'ts - TypeScript
Recommendations for writing d.ts files. ... WRONG */. function reverse(s: String): String;. ✓ Do use the types number , string , boolean ,...
Read more >Permanent warning "Your project contained an invalid value ...
Run npx typescript --init (or add a basic tsconfig.json file); Open the new project in Visual Studio; See the warning showing up in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i was getting the same error and when i provide the full path it is work with me (i am using windows 10) or you can open the terminal with the current directory of the file you need to test and provide the command with the file name only (using vscode) => ngentest “filename”
even i am getting the same issue