Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: ensure integration tests can fail, add vue-sfc (#768)
- Loading branch information
1 parent
3777b77
commit f953cbd
Showing
11 changed files
with
195 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
root: true | ||
|
||
parser: 'vue-eslint-parser' | ||
|
||
env: | ||
es6: true | ||
node: true | ||
|
||
parserOptions: | ||
# Local version of @typescript-eslint/parser | ||
parser: '@typescript-eslint/parser' | ||
project: /usr/linked/tsconfig.json | ||
sourceType: module | ||
extraFileExtensions: ['.vue'] | ||
|
||
plugins: | ||
# Local version of @typescript-eslint/eslint-plugin | ||
- '@typescript-eslint' | ||
|
||
rules: | ||
'@typescript-eslint/no-explicit-any': 'error' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM node:carbon | ||
|
||
# Copy the test.sh into the container. Every other file will be linked, rather | ||
# than copied to allow for changes without rebuilds wherever possible | ||
WORKDIR /usr | ||
COPY ./test.sh /usr/ | ||
|
||
# Create file which will be executed by jest | ||
# to assert that the lint output is what we expect | ||
RUN echo "const actualLintOutput = require('./lint-output.json');\n" \ | ||
"\n" \ | ||
"test('it should produce the expected lint ouput', () => {\n" \ | ||
" expect(actualLintOutput).toMatchSnapshot();\n" \ | ||
"});\n" > test.js | ||
|
||
# Run the integration test | ||
CMD [ "./test.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!-- Hello.vue --> | ||
<template> | ||
<div> | ||
<div> | ||
<!-- !!!!! expected error !!!!! --> | ||
Hello {{ (name as any) }}{{exclamationMarks}} | ||
</div> | ||
<button @click="decrement">-</button> | ||
<button @click="increment">+</button> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from "vue"; | ||
export default Vue.extend({ | ||
props: ['name', 'initialEnthusiasm'], | ||
data() { | ||
return { | ||
enthusiasm: this.initialEnthusiasm, | ||
} | ||
}, | ||
methods: { | ||
increment() { this.enthusiasm++; }, | ||
decrement() { | ||
if (this.enthusiasm > 1) { | ||
this.enthusiasm--; | ||
} | ||
}, | ||
}, | ||
computed: { | ||
exclamationMarks(): any { // !!!!! expected error !!!!! | ||
return Array(this.enthusiasm + 1).join('!'); | ||
} | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`it should produce the expected lint ouput 1`] = ` | ||
Array [ | ||
Object { | ||
"errorCount": 1, | ||
"filePath": "/usr/linked/Hello.vue", | ||
"fixableErrorCount": 0, | ||
"fixableWarningCount": 0, | ||
"messages": Array [ | ||
Object { | ||
"column": 29, | ||
"endColumn": 32, | ||
"endLine": 31, | ||
"line": 31, | ||
"message": "Unexpected any. Specify a different type.", | ||
"messageId": "unexpectedAny", | ||
"nodeType": "TSAnyKeyword", | ||
"ruleId": "@typescript-eslint/no-explicit-any", | ||
"severity": 2, | ||
}, | ||
], | ||
"source": "<!-- Hello.vue --> | ||
<template> | ||
<div> | ||
<div> | ||
<!-- !!!!! expected error !!!!! --> | ||
Hello {{ (name as any) }}{{exclamationMarks}} | ||
</div> | ||
<button @click=\\"decrement\\">-</button> | ||
<button @click=\\"increment\\">+</button> | ||
</div> | ||
</template> | ||
<script lang=\\"ts\\"> | ||
import Vue from \\"vue\\"; | ||
export default Vue.extend({ | ||
props: ['name', 'initialEnthusiasm'], | ||
data() { | ||
return { | ||
enthusiasm: this.initialEnthusiasm, | ||
} | ||
}, | ||
methods: { | ||
increment() { this.enthusiasm++; }, | ||
decrement() { | ||
if (this.enthusiasm > 1) { | ||
this.enthusiasm--; | ||
} | ||
}, | ||
}, | ||
computed: { | ||
exclamationMarks(): any { // !!!!! expected error !!!!! | ||
return Array(this.enthusiasm + 1).join('!'); | ||
} | ||
} | ||
}); | ||
</script> | ||
", | ||
"warningCount": 0, | ||
}, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# Generate the package.json to use | ||
node /usr/utils/generate-package-json.js | ||
|
||
# Install dependencies | ||
npm install | ||
|
||
# Use the local volumes for our own packages | ||
npm install $(npm pack /usr/typescript-estree | tail -1) | ||
npm install $(npm pack /usr/parser | tail -1) | ||
npm install $(npm pack /usr/eslint-plugin | tail -1) | ||
|
||
# Install the latest vue-eslint-parser (this may break us occassionally, but it's probably good to get that feedback early) | ||
npm install vue-eslint-parser@latest | ||
|
||
# Run the linting | ||
# (the "|| true" helps make sure that we run our tests on failed linting runs as well) | ||
npx eslint --format json --output-file /usr/lint-output.json --config /usr/linked/.eslintrc.yml /usr/linked/**/*.vue || true | ||
|
||
# Run our assertions against the linting output | ||
npx jest /usr/test.js --snapshotResolver=/usr/utils/jest-snapshot-resolver.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Ensure child script failures are propagated | ||
set -e | ||
|
||
# We run the services serially and in a non-detached state just that we can ensure predictable | ||
# exit codes for all of our integration tests, and we can ensure CI builds pass or fail appropriately | ||
|
||
# typescript-and-tslint-plugins-together | ||
docker-compose -f tests/integration/docker-compose.yml up --build --abort-on-container-exit typescript-and-tslint-plugins-together | ||
|
||
# vue-sfc | ||
docker-compose -f tests/integration/docker-compose.yml up --build --abort-on-container-exit vue-sfc |