mutation-testing-elements icon indicating copy to clipboard operation
mutation-testing-elements copied to clipboard

TestFiles should have a Language property for syntax highlighting

Open rouke-broersma opened this issue 4 years ago • 8 comments

Source files have a Language property that can be set which is used for syntax highlighting. Test files don't seem to have this property. This should be available so the syntax highlighting of test files can use the proper language highlighting.

rouke-broersma avatar Nov 06 '21 18:11 rouke-broersma

I don't like that to be honest. We base syntax highlighting of test files on the extension, which should be the case for source files as well.

nicojs avatar Nov 06 '21 20:11 nicojs

File extensions don't necessarily have to be correct on all platforms, systems and ecosystems. There might even be conflicting file extensions between languages. I think it's safer if the tool generating the report specifies which language the files are since they will know best. Mutation testing elements can make a best effort guess, the mutation testing tool will know for sure.

rouke-broersma avatar Nov 07 '21 01:11 rouke-broersma

Yes, that makes sense, but couldn't I can't come up with an example of overlapping file and language types. In general, we are pretty good at coming up with unique extensions for source code files.

What is the use case for language, other than syntax highlighting? Because we only support a small subset of languages for syntax highlighting and I know for sure there is no overlap in these file extensions.

nicojs avatar Nov 07 '21 09:11 nicojs

The case comes first and foremost from a consistency perspective. Files have a language property, TestFiles do not.

rouke-broersma avatar Nov 07 '21 10:11 rouke-broersma

In that case I can agree with an optional language property. I would also opt to make the language property optional for source files 🤷‍♀️

nicojs avatar Nov 08 '21 12:11 nicojs

I don't think I've ever seen an inconsistent filename for source files. But adding a language might be more beneficial for places where we've forgotten to add support for the filename in the report. For Node, there's a huge number of extensions you can have (js, ts, jsx, jsm and some combinations of all those)

hugo-vrijswijk avatar Nov 08 '21 14:11 hugo-vrijswijk

Yes, so either I place the logic of extension recognition in StrykerJS, or in mutation-testing-elements. I personally prefer mutation-testing-elements in that case, closer to the "view" 🤷‍♂️.

Either way it should be optional, as code highlighting is not required for a report.

nicojs avatar Nov 09 '21 07:11 nicojs

Imo the schema should be as platform independent as possible. If you put the language detection in html elements any other consumer of the json would also need to implement language detection. I think it's cleaner to provide a complete json containing all information necessary.

rouke-broersma avatar Nov 09 '21 07:11 rouke-broersma