What this answers
This test answers "do my observed category counts look like they came from the distribution I claimed, or is there evidence the true distribution is different?" It works on a single categorical variable with two or more categories, comparing observed counts against the counts you would expect under a stated model.
How it is calculated
Each category's expected count is your stated proportion multiplied by the total sample size. The chi-square statistic sums, across every category, the squared difference between observed and expected counts divided by the expected count. Degrees of freedom equal the number of categories minus 1, minus one further degree of freedom for each additional parameter you estimated from the data itself to build the expected proportions (leave this at 0 if your expected proportions were fixed in advance, not fitted).
Worked example
For six die faces observed 8, 9, 19, 5, 8, and 11 times (60 rolls total) against an equal one-sixth expectation for each face, the expected count per face is 10, and the chi-square statistic works out to 11.6 on 5 degrees of freedom. That combination gives a p-value in roughly the .04 range, evidence against the fair-die model at the conventional .05 threshold, driven mostly by the unusually high count of 19 on one face.
Assumption audit
What this result does not mean
A significant chi-square result means the observed counts are unlikely under the stated model, not that you know which alternative model is correct or by how much each category deviates in a meaningful practical sense. It also does not identify which single category caused the misfit without further inspection of the expected-versus-observed counts above.
Limitations
With low expected counts in any category, the chi-square approximation to the true sampling distribution degrades; the warning above flags this so you know when to treat the p-value with caution or consider combining sparse categories before testing.