Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit dde8275

Browse files
authored
feat: add typescript support (#95)
⚠️ does not filter specs if they have `interface` or `type` keyword, so those tests will be skipped * adding TypeScript and a TS spec * feat: add typescript spec file support * try to confirm filtering ts specs
1 parent ffa0608 commit dde8275

File tree

7 files changed

+58
-11
lines changed

7 files changed

+58
-11
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,13 @@ jobs:
372372
--env grepUntagged=true \
373373
--expect-exactly expects/describe-tags-spec-untagged.json
374374
375+
- name: filter TypeScript spec 🧪
376+
run: |
377+
npx cypress-expect \
378+
--config testFiles="**/ts-spec.ts" \
379+
--env grep=loads,grepOmitFiltered=true,grepFilterSpecs=true \
380+
--expect-exactly expects/ts-spec.json
381+
375382
release:
376383
needs: [tests1, tests2, tests3]
377384
runs-on: ubuntu-20.04

cypress/integration/ts-spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
describe('TypeScript spec', () => {
2+
it('works', () => {
3+
type Person = {
4+
name: string
5+
}
6+
7+
const person: Person = {
8+
name: 'Joe',
9+
}
10+
11+
cy.wrap(person).should('have.property', 'name', 'Joe')
12+
})
13+
14+
it('loads', () => {
15+
const n: number = 1
16+
cy.wrap(n).should('eq', 1)
17+
})
18+
})

cypress/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"types": ["cypress"]
4+
},
5+
"files": [
6+
"./integration/**/*.ts"
7+
],
8+
}

expects/ts-spec.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"TypeScript spec": {
3+
"loads": "passing"
4+
}
5+
}

package-lock.json

Lines changed: 15 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@
2020
"cypress-each": "^1.5.0",
2121
"cypress-expect": "2.5.0",
2222
"prettier": "2.3.1",
23-
"semantic-release": "17.4.3"
23+
"semantic-release": "17.4.3",
24+
"typescript": "^4.5.4"
2425
},
2526
"repository": {
2627
"type": "git",
2728
"url": "https://github.com/bahmutov/cypress-grep.git"
2829
},
2930
"dependencies": {
3031
"debug": "4.3.1",
31-
"find-test-names": "^1.2.1",
32+
"find-test-names": "^1.3.0",
3233
"globby": "^11.0.4"
3334
}
3435
}

src/plugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ function cypressGrepPlugin(config) {
8282
return shouldRun
8383
})
8484
} catch (err) {
85+
debug(err.message)
86+
debug(err.stack)
8587
console.error('Could not determine test names in file: %s', specFile)
8688
console.error('Will run it to let the grep filter the tests')
8789
return true

0 commit comments

Comments
 (0)