magnificent-finland-58048
05/20/2022, 3:24 PMnpm run cypress open
and npm run cypress open-ct
. ?magnificent-finland-58048
05/20/2022, 3:25 PMkind-artist-70775
05/20/2022, 3:30 PMkind-artist-70775
05/20/2022, 3:31 PMkind-artist-70775
05/20/2022, 3:31 PMkind-artist-70775
05/20/2022, 3:31 PMcy.js
i'm not following? what do you mean?kind-artist-70775
05/20/2022, 3:33 PMopen-ct
is the convention for Component tests (which is what I have urgency with)kind-artist-70775
05/20/2022, 3:35 PMoptions
hash which is populated when running and this allows me to see the configured directories. I would say there are likely some defects that jump out (unless I'm misinterepting) but with that feedback loop I can modify config until it's at a place where it should be working ... but it doesn'tkind-artist-70775
05/20/2022, 3:36 PMkind-artist-70775
05/20/2022, 3:39 PMkind-artist-70775
05/20/2022, 3:41 PMkind-artist-70775
05/20/2022, 3:41 PMkind-artist-70775
05/20/2022, 3:44 PMkind-artist-70775
05/20/2022, 3:46 PMexport default defineConfig({})
to ensure people have this meta info available easily without having to search types ... so far it seems Cypress keeps their internal types rather hard to reach for (at least for library authors or people who want typing in their config).bland-lamp-18095
05/20/2022, 4:01 PMwonderful-match-15836
05/20/2022, 8:22 PMcomponentFolder
as test/fixtures
. Cypress will look for your testFiles
pattern to be matched inside the componentFolder
you define. Which is not going to work since you probably do not have specs in your fixtures folder. This is mentioned in the guide from the docs: https://docs.cypress.io/guides/component-testing/framework-configuration#Vue-2-Vue-CLI
You can try removing the componentFolder
completely from the component
config (since your pattern includes the folder you want) or changing it to where you want Cypress to look for component specs. I would guess this is probably what's blocking you. Let me know if you've already tried removing/renaming componentFolder
and Cypress still could not find specs.kind-artist-70775
05/20/2022, 8:40 PMvite-plugin-md
plugin which uses Vite to transform the MD files to components so it is in fact the directory where my "components" reside. I did move test files into the fixtures directory to see if I could get this to work but it didn't recognize it there either.kind-artist-70775
05/20/2022, 8:41 PMintegration/plugins/index.ts
file:
ts
import path from 'path'
import { startDevServer } from '@cypress/vite-dev-server'
export default function (on, config) {
console.log(config)
on('dev-server:start', (options) => {
return startDevServer({
options,
viteConfig: {
configFile: path.resolve(process.cwd(), 'vite.config.ts'),
logLevel: 'error',
},
})
})
return config
}
broad-businessperson-13175
05/20/2022, 9:23 PMnpx cypress cache clear
and then install cypress again? Thinking you need to clear the cache, this can solve the issueaverage-horse-98297
05/20/2022, 11:06 PMbetter-house-96424
05/21/2022, 3:03 AM/cypress/support/index.ts
?
I'm trying to import my graphql schema file schema.graphql
as a string so I can pass it to my auto mock generator.
But it complains about not having the right loader for that file if I try to just import it. Same if I try to import it with raw.
import schema from './schema.graphql?raw'
I also tried specifically adding raw-loader
and setting it up in cypress/webpack.config.js
with no luck.
It also seems like I can't import fs
in this file, so I can't use fs.readFile
either ๐
Anyone knows or have any other ideas on how I can import a .graphql
file as a string?fresh-doctor-14925
05/21/2022, 6:28 AMfresh-doctor-14925
05/21/2022, 6:30 AMfs.readFile
For importing the file itself, you could use cy.readFile()
silly-area-58114
05/21/2022, 1:13 PMbetter-house-96424
05/21/2022, 4:41 PMcy.readFile
as well. But it complains that a cy.x can't contain another promise also related to cy.y
This is my code in support/index.ts
ts
Cypress.on('window:before:load', (win) => {
const originalFunction = win.fetch
// ๐ I tried adding cy.readFile(xxx).then here, but it failed.
function fetchStub(_path, request) {
if (request && request.body) {
// Using operation name of the request to look for response mock data
const requestBody = JSON.parse(request.body)
const schema = buildClientSchema(SCHEMA_AS_STRING) // ๐ This is where I need to use the schema file as a string.
let mocks = defaultMocks
const mockResponse: any = ergonomock(schema, requestBody.query, {
variables: requestBody.variables,
seed: 'colony',
mocks,
})
if (mockResponse) {
// If operation mock is found, mock the response
return _responseStub(mockResponse.data)
}
}
// If request mock data not found, we do not mock the request
return originalFunction.apply(this, arguments)
}
// Mocking all fetch actions that are called with `/graphql` endpoint
cy.stub(win, 'fetch', fetchStub).withArgs('/graphql').as('graphqlStub')
})
gray-kilobyte-89541
05/21/2022, 7:27 PMfresh-doctor-14925
05/21/2022, 7:28 PMcy.intercept ()
in the body of your test instead?
Iโve been able to stub graph calls before (and generate fixtures based on the schema). This blog served as my starting point
https://docs.cypress.io/guides/testing-strategies/working-with-graphqlflat-waitress-43696
05/22/2022, 8:55 AMfresh-doctor-14925
05/22/2022, 11:35 AMflat-waitress-43696
05/22/2022, 11:36 AM